Browse Source

rework stuff

main
Hendrik Langer 7 years ago
parent
commit
d1f6501145
  1. 2
      platformio.ini
  2. 1
      src/AlarmClock.cpp
  3. 7
      src/main.cpp
  4. 6
      src/main.h
  5. 15
      src/screen.cpp
  6. 1
      src/screen.h

2
platformio.ini

@ -15,7 +15,7 @@ board = heltec_wifi_lora_32
board_f_cpu = 240000000L
board_f_flash = 80000000L
framework = arduino
build_flags = -DLOG_LOCAL_LEVEL=ESP_LOG_VERBOSE -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_VERBOSE -DDEBUG_INT_ALLOC_DECISIONS=1
;build_flags = -DLOG_LOCAL_LEVEL=ESP_LOG_VERBOSE -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_VERBOSE -DDEBUG_INT_ALLOC_DECISIONS=1
; -DCONFIG_ESP32_RTC_CLOCK_SOURCE_EXTERNAL_CRYSTAL=y
board_build.partitions = min_spiffs.csv
; http://docs.platformio.org/en/latest/platforms/espressif32.html#partition-tables https://github.com/espressif/arduino-esp32/tree/master/tools/partitions

1
src/AlarmClock.cpp

@ -101,6 +101,7 @@ bool AlarmClock::isNTPExpired(void) {
bool AlarmClock::updateNTPTime(void) {
ESP_LOGI(TAG, "Getting time over NTP.");
lastNTPRequest = millis();
sntp_setoperatingmode(SNTP_OPMODE_POLL);
sntp_setservername(0, "de.pool.ntp.org");
sntp_init();

7
src/main.cpp

@ -404,12 +404,13 @@ void loop()
led.wakeUpLight(255*(-seconds+300)/300);
}
int voltage = rom_phy_get_vdd33();
Serial.printf("voltage: %d\n", voltage);
state.voltage = rom_phy_get_vdd33();
state.rssi = WiFi.RSSI();
Serial.printf("voltage: %d\n", state.voltage);
if (alarmclock.isTimeValid()) alarmclock.getTime(state.timeStr, sizeof(state.timeStr), "%H:%M:%S", TIME_CURRENT);
sprintf(state.string1, "%.1f°C %.1f%% %.0fhPa", bme280.readTemperature(), bme280.readHumidity(), bme280.readPressure());
sprintf(state.string2, "%.1f %dmV %ddBm %ukB %s", temperatureRead(), voltage, WiFi.RSSI(), ESP.getFreeHeap()/1024, alarmclock.isAlarmArmed()?"A":"_");
sprintf(state.string2, "%.1f %dmV %ddBm %ukB %s", temperatureRead(), state.voltage, WiFi.RSSI(), ESP.getFreeHeap()/1024, alarmclock.isAlarmArmed()?"A":"_");
Serial.print("Free Heap: ");
Serial.println(ESP.getFreeHeap());

6
src/main.h

@ -31,9 +31,9 @@ struct __attribute__((packed)) WEBRADIO_STATE {
/* float temperature;
float humidity;
float pressure;
float temp2;
float voltage;
float rssi;*/
float temp2;*/
int voltage;
int32_t rssi;
};
#endif /* _MAIN_H */

15
src/screen.cpp

@ -243,6 +243,8 @@ void WelcomeScreen::draw() {
u8g2.clearBuffer(); // clear the internal memory
u8g2.setFont(u8g2_font_ncenB08_tr); // choose a suitable font
u8g2.drawStr(2,10,"esp32-node by hendrik"); // write something to the internal memory
// u8g2.setFont(u8g2_font_profont29_tr);
// u8g2.drawStr(2,10,"xd0");
if (iot.configuration.get("WifiConfigured") != "True") {
u8g2.drawStr(2,30,"NOT CONFIGURED!");
u8g2.drawStr(12,40,"SSID: \"ESP32\"");
@ -260,6 +262,19 @@ void WelcomeScreen::draw() {
u8g2.sendBuffer(); // transfer internal memory to the display
}
void Screen::drawStatusBar(uint8_t y_offset) {
u8g2.setFont(u8g2_font_open_iconic_embedded_2x_t);
u8g2.drawUTF8(0, y_offset, "\xab");
if (alarmclock.isAlarmArmed()) u8g2.drawGlyph(5, y_offset, 0x0041); // Alarmclock symbol
else {}
u8g2.setFont(u8g2_font_inb16_mr);
u8g2.drawUTF8(0, 20, state.timeStr);
u8g2.setFont(u8g2_font_open_iconic_embedded_2x_t);
u8g2.drawGlyph(5, y_offset, 0x0050); // Wifi symbol
if (state.voltage > 3000) u8g2.drawGlyph(5, y_offset, 0x0049); // Battery symbol
else u8g2.drawGlyph(5, y_offset, 0x0040); // Battery symbol
}
void MainScreen::draw() {
u8g2.clearBuffer(); // clear the internal memory

1
src/screen.h

@ -44,6 +44,7 @@ class Screen {
virtual void previous(void);
virtual uint8_t select(void);
const char* title = "Test Screen";
virtual void drawStatusBar(uint8_t y_offset);
private:
};

Loading…
Cancel
Save