@ -9,46 +9,32 @@
class DisplayMono84X48 : public DisplayMono {
public :
DisplayMono84X48 ( ) : DisplayMono ( ) {
mEnPowerSaf e = true ;
mEnPowerSav e = true ;
mEnScreenSaver = true ;
mLuminance = 6 0;
mLuminance = 14 0;
mExtra = 0 ;
mDispY = 0 ;
mTimeout = DISP_DEFAULT_TIMEOUT ; // interval at which to power save (milliseconds)
mUtcTs = NULL ;
mType = 0 ;
mDispWidth = 0 ;
}
void init ( uint8_t type , uint8_t rotation , uint8_t cs , uint8_t dc , uint8_t reset , uint8_t clock , uint8_t data , uint32_t * utcTs , const char * version ) {
void config ( bool enPowerSave , bool enScreenSaver , uint8_t lum ) {
mEnPowerSave = enPowerSave ;
mEnScreenSaver = enScreenSaver ;
mLuminance = lum ;
}
void init ( uint8_t type , uint8_t rotation , uint8_t cs , uint8_t dc , uint8_t reset , uint8_t clock , uint8_t data , DisplayData * displayData ) {
u8g2_cb_t * rot = ( u8g2_cb_t * ) ( ( rotation ! = 0x00 ) ? U8G2_R2 : U8G2_R0 ) ;
mType = type ;
mDisplay = new U8G2_PCD8544_84X48_F_4W_SW_SPI ( rot , clock , data , cs , dc , reset ) ;
mUtcTs = utcTs ;
mDisplay - > begin ( ) ;
mDispWidth = mDisplay - > getDisplayWidth ( ) ;
monoInit ( new U8G2_PCD8544_84X48_F_4W_SW_SPI ( rot , clock , data , cs , dc , reset ) , type , displayData ) ;
calcLinePositions ( ) ;
mDisplay - > clearBuffer ( ) ;
mDisplay - > setContrast ( mLuminance ) ;
printText ( " AHOY! " , l_Ahoy ) ;
printText ( " Ahoy! " , l_Ahoy ) ;
printText ( " ahoydtu.de " , l_Website ) ;
printText ( version , l_Version ) ;
printText ( mDisplayData - > version , l_Version ) ;
mDisplay - > sendBuffer ( ) ;
}
void config ( bool enPowerSafe , bool enScreenSaver , uint8_t lum ) {
mEnPowerSafe = enPowerSafe ;
mEnScreenSaver = enScreenSaver ;
mLuminance = lum ;
}
void loop ( uint8_t lum ) {
if ( mEnPowerSaf e ) {
if ( mEnPowerSave ) {
if ( mTimeout ! = 0 )
mTimeout - - ;
}
@ -59,43 +45,43 @@ class DisplayMono84X48 : public DisplayMono {
}
}
void disp ( float totalPower , float totalYieldDay , float totalYieldTotal , uint8_t ispro d) {
void disp ( voi d) {
mDisplay - > clearBuffer ( ) ;
// set Contrast of the Display to raise the lifetime
mDisplay - > setContrast ( mLuminance ) ;
if ( ( totalPower > 0 ) & & ( isprod > 0 ) ) {
if ( ( mDisplayData - > totalPower > 0 ) & & ( mD isplayData - > isP roducing > 0 ) ) {
mTimeout = DISP_DEFAULT_TIMEOUT ;
mDisplay - > setPowerSave ( false ) ;
if ( totalPower > 999 )
snprintf ( mFmtText , DISP_FMT_TEXT_LEN , " %.2f kW " , ( totalPower / 1000 ) ) ;
if ( mDisplayData - > totalPower > 999 )
snprintf ( mFmtText , DISP_FMT_TEXT_LEN , " %.2f kW " , ( mDisplayData - > totalPower / 1000 ) ) ;
else
snprintf ( mFmtText , DISP_FMT_TEXT_LEN , " %.0f W " , totalPower ) ;
snprintf ( mFmtText , DISP_FMT_TEXT_LEN , " %.0f W " , mDisplayData - > totalPower ) ;
printText ( mFmtText , l_TotalPower ) ;
} else {
printText ( " offline " , l_TotalPower ) ;
// check if it's time to enter power saving mode
if ( mTimeout = = 0 )
mDisplay - > setPowerSave ( mEnPowerSaf e ) ;
mDisplay - > setPowerSave ( mEnPowerSav e ) ;
}
snprintf ( mFmtText , DISP_FMT_TEXT_LEN , " Today: %4.0f Wh " , totalYieldDay ) ;
snprintf ( mFmtText , DISP_FMT_TEXT_LEN , " Today: %.0f Wh " , mDisplayData - > totalYieldDay ) ;
printText ( mFmtText , l_YieldDay ) ;
snprintf ( mFmtText , DISP_FMT_TEXT_LEN , " Total: %.1f kWh " , totalYieldTotal ) ;
snprintf ( mFmtText , DISP_FMT_TEXT_LEN , " Total: %.1f kWh " , mDisplayData - > totalYieldTotal ) ;
printText ( mFmtText , l_YieldTotal ) ;
if ( NULL ! = mU tcTs)
printText ( ah : : getDateTimeStrShort ( gTimezone . toLocal ( * mU tcTs) ) . c_str ( ) , l_Time ) ;
if ( 0 ! = mDisplayData - > u tcTs)
printText ( ah : : getDateTimeStrShort ( gTimezone . toLocal ( mDisplayData - > u tcTs) ) . c_str ( ) , l_Time ) ;
IPAddress ip = WiFi . localIP ( ) ;
if ( ! ( mExtra % 5 ) & & ( ip ) )
snprintf ( mFmtText , DISP_FMT_TEXT_LEN , " %s " , ip . toString ( ) . c_str ( ) ) ;
if ( ! ( mExtra % 5 ) & & ( mDisplayData - > ipAddress ) )
snprintf ( mFmtText , DISP_FMT_TEXT_LEN , " %s " , ( mDisplayData - > ipAddress ) . toString ( ) . c_str ( ) ) ;
else
snprintf ( mFmtText , DISP_FMT_TEXT_LEN , " Inv.On: %d " , isprod ) ;
snprintf ( mFmtText , DISP_FMT_TEXT_LEN , " Inv.On: %d " , mD isplayData - > isP roducing ) ;
printText ( mFmtText , l_Status ) ;
mDisplay - > sendBuffer ( ) ;
@ -153,3 +139,4 @@ class DisplayMono84X48 : public DisplayMono {
mDisplay - > drawStr ( dispX , mLineYOffsets [ line ] , text ) ;
}
} ;