Browse Source

gamma correction and status string

main
Hendrik Langer 7 years ago
parent
commit
de42c1cc47
  1. 2
      src/alarmsound.h
  2. 5
      src/led.cpp
  3. 10
      src/main.cpp
  4. 3
      src/mp3.cpp
  5. 2
      src/screen.cpp
  6. 1
      src/screen.h

2
src/alarmsound.h

@ -2,7 +2,7 @@
* under Creative Commons 0 License * under Creative Commons 0 License
* https://freesound.org/people/Rudmer_Rotteveel/sounds/316920/ */ * https://freesound.org/people/Rudmer_Rotteveel/sounds/316920/ */
unsigned char alarmsound[] = { const unsigned char alarmsound[] PROGMEM = {
0xff, 0xfb, 0x90, 0xc4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xfb, 0x90, 0xc4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49, 0x6e, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49, 0x6e, 0x66,
0x6f, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x4c, 0x6f, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x4c,

5
src/led.cpp

@ -47,7 +47,7 @@ void Led::loop_off(void) {
if (wakeupIndex > 240) color = CRGB::White; if (wakeupIndex > 240) color = CRGB::White;
fill_solid(leds, NUM_LEDS, color); fill_solid(leds, NUM_LEDS, color);
// fadeToBlackBy( leds, NUM_LEDS, 255-wakeupIndex); // fadeToBlackBy( leds, NUM_LEDS, 255-wakeupIndex);
FastLED.setBrightness(wakeupIndex); setBrightness(wakeupIndex);
if (wakeupIndex < 100) { if (wakeupIndex < 100) {
leds[3] = CRGB::Black; leds[3] = CRGB::Black;
leds[NUM_LEDS-4] = CRGB::Black; leds[NUM_LEDS-4] = CRGB::Black;
@ -95,7 +95,8 @@ void Led::setBrightness(uint8_t brightness) {
if (brightness > 254) { // don't set first byte to 255 on tm1829 if (brightness > 254) { // don't set first byte to 255 on tm1829
FastLED.setBrightness(254); FastLED.setBrightness(254);
} else { } else {
FastLED.setBrightness(brightness); uint8_t b = pow(((double)brightness/255.0), 4.2) * 255.0;
FastLED.setBrightness(b);
} }
} }

10
src/main.cpp

@ -40,7 +40,7 @@
extern "C" { extern "C" {
int rom_phy_get_vdd33(); int rom_phy_get_vdd33();
//uint8_t temprature_sens_read(); uint8_t temprature_sens_read();
//uint32_t hall_sens_read(); //uint32_t hall_sens_read();
} }
@ -49,6 +49,7 @@ U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ 16, /* clock=*/ 15
char timeStr[20]; char timeStr[20];
char weatherStr[32]; char weatherStr[32];
char statusStr[32];
RTC_DATA_ATTR static int boot_count = 0; RTC_DATA_ATTR static int boot_count = 0;
RTC_DATA_ATTR struct tm alarmTime; RTC_DATA_ATTR struct tm alarmTime;
RTC_DATA_ATTR bool alarmArmed = false; RTC_DATA_ATTR bool alarmArmed = false;
@ -382,9 +383,10 @@ void loop()
lastButtonPress = millis(); lastButtonPress = millis();
led.wakeUpLight(0); led.wakeUpLight(0);
Serial.println("WAKEUP TIME!!!!!"); Serial.println("WAKEUP TIME!!!!!");
mp3.setVolume(2); // mp3.setVolume(10);
// mp3.start_Progmem(); // mp3.start_Progmem();
// delay(1500); // delay(1500);
mp3.setVolume(2);
mp3.start("http://radioessen.cast.addradio.de/radioessen/simulcast/high/stream.mp3"); mp3.start("http://radioessen.cast.addradio.de/radioessen/simulcast/high/stream.mp3");
led.changeAnimation(2, 0); led.changeAnimation(2, 0);
} }
@ -396,8 +398,8 @@ void loop()
Serial.printf("voltage: %d\n", voltage); Serial.printf("voltage: %d\n", voltage);
strftime(timeStr, sizeof(timeStr), "%H:%M:%S", &timeinfo); strftime(timeStr, sizeof(timeStr), "%H:%M:%S", &timeinfo);
sprintf(weatherStr, "%.1f°C %.1f%% %dmV", bme280.readTemperature(), bme280.readHumidity(), voltage); sprintf(weatherStr, "%.1f°C %.1f%% %.0fhPa", bme280.readTemperature(), bme280.readHumidity(), bme280.readPressure());
// sprintf(weatherStr, "%.1f°C %.1f%% %.0fhPa", bme280.readTemperature(), bme280.readHumidity(), bme280.readPressure()); sprintf(statusStr, "%.1f°C %dmV %u %s", temperatureRead(), voltage, ESP.getFreeHeap()/1024, isAlarmActive()?"A":"_");
Serial.print("Free Heap: "); Serial.print("Free Heap: ");
Serial.println(ESP.getFreeHeap()); Serial.println(ESP.getFreeHeap());

3
src/mp3.cpp

@ -23,6 +23,7 @@
char titleStr[64]; char titleStr[64];
// convert mp3 files with `xxd -i alarm.wav > alarmsound.h` // convert mp3 files with `xxd -i alarm.wav > alarmsound.h`
// has to be: const unsigned char alarmsound[] PROGMEM = ...
MP3::MP3() { MP3::MP3() {
strncpy_P(URL, "http://streaming.shoutcast.com/80sPlanet?lang=en-US", sizeof(URL)); strncpy_P(URL, "http://streaming.shoutcast.com/80sPlanet?lang=en-US", sizeof(URL));
@ -107,7 +108,7 @@ void MP3::mp3_decoder_task(void *pvParameters) {
// strcpy(titleStr, "loading..."); // strcpy(titleStr, "loading...");
if (fromProgmem) file = new AudioFileSourcePROGMEM(alarmsound, sizeof(alarmsound)); if (fromProgmem) file = new AudioFileSourcePROGMEM(alarmsound, alarmsound_len);
else file = new AudioFileSourceICYStream(URL); else file = new AudioFileSourceICYStream(URL);
file->RegisterMetadataCB(MDCallback, (void*)"ICY"); file->RegisterMetadataCB(MDCallback, (void*)"ICY");
buff = new AudioFileSourceBuffer(file, preallocateBuffer, preallocateBufferSize); buff = new AudioFileSourceBuffer(file, preallocateBuffer, preallocateBufferSize);

2
src/screen.cpp

@ -256,7 +256,7 @@ void MainScreen::draw() {
u8g2.setFont(u8g2_font_profont12_mf); // choose a suitable font u8g2.setFont(u8g2_font_profont12_mf); // choose a suitable font
u8g2.drawUTF8(0, 30, weatherStr); u8g2.drawUTF8(0, 30, weatherStr);
if (isAlarmActive()) u8g2.drawUTF8(110,42, "A"); u8g2.drawUTF8(0,42, statusStr);
u8g2.setFont(u8g2_font_prospero_bold_nbp_tf); // choose a suitable font u8g2.setFont(u8g2_font_prospero_bold_nbp_tf); // choose a suitable font

1
src/screen.h

@ -27,6 +27,7 @@ enum menuType { eNone=0, eWelcomeScreen, eMainScreen, eMainMenu, eStationMenu, e
extern U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2; extern U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2;
extern char timeStr[]; extern char timeStr[];
extern char weatherStr[]; extern char weatherStr[];
extern char statusStr[];
extern BME280 bme280; extern BME280 bme280;
extern MP3 mp3; extern MP3 mp3;
extern menuType menuChange; extern menuType menuChange;

Loading…
Cancel
Save