diff --git a/D4han.ino b/D4han.ino index 861735d..c2b9ed7 100644 --- a/D4han.ino +++ b/D4han.ino @@ -26,12 +26,13 @@ M5.begin(115200); M5.Lcd.setRotation(3); + spu.setColorDepth(8); spu.createSprite(240, 135); M5.Lcd.setTextSize(2); - M5.Lcd.fillScreen(TFT_BLUE); + M5.Lcd.fillScreen(TFT_YELLOW); M5.Lcd.setTextSize(2); M5.Lcd.setTextColor(TFT_BLACK); M5.Lcd.setCursor(5, 5); @@ -45,7 +46,7 @@ } void loop() { - static int i = 4; //initializing + static int i = 3; while (i > 0) { if (millis() - last_millis > 1000) { last_millis = millis(); @@ -68,16 +69,18 @@ return; } - spu.fillSprite(LIGHTGREY); + if ( sgp.eCO2 >= 1000) { + + spu.fillSprite( DARKGREY ); //変更点 spu.setCursor(93, 5, 4); spu.setTextSize(2); - spu.setTextColor( BLACK, LIGHTGREY); + spu.setTextColor( WHITE, BLUE ); spu.printf(" %d \n", sgp.TVOC); spu.setCursor(93, 65, 4); spu.setTextSize(2); - spu.setTextColor( BLACK, LIGHTGREY); + spu.setTextColor( WHITE, BLUE ); spu.printf(" %d \n", sgp.eCO2); - spu.setTextColor( BLUE, LIGHTGREY); + spu.setTextColor( BLUE, CYAN); spu.setCursor(10, 20, 4); spu.setTextSize(1); spu.println("TVOC : "); spu.setCursor(10, 80, 4); spu.setTextSize(1); @@ -85,23 +88,83 @@ spu.pushSprite(0, 0); // 画面に反映させる - Serial.printf("TVOC: %d eCO2: %d\n", sgp.TVOC, sgp.eCO2); + } else if ( sgp.eCO2<1000 && sgp.eCO2 >= 700 ) { + + spu.fillSprite( DARKGREEN ); //変更点 + spu.setCursor(93, 5, 4); spu.setTextSize(2); + spu.setTextColor( WHITE, BLUE ); + spu.printf(" %d \n", sgp.TVOC); + + spu.setCursor(93, 65, 4); spu.setTextSize(2); + spu.setTextColor( WHITE, BLUE ); + spu.printf(" %d \n", sgp.eCO2); + + spu.setTextColor( BLUE, CYAN); + spu.setCursor(10, 20, 4); spu.setTextSize(1); + spu.println("TVOC : "); + spu.setCursor(10, 80, 4); spu.setTextSize(1); + spu.println("eCO2 : "); + + spu.pushSprite(0, 0); // 画面に反映させる + + } else if ( sgp.eCO2<700 && sgp.eCO2 >= 450 ) { + + spu.fillSprite( GREEN ); // 変更点 + spu.setCursor(93, 5, 4); spu.setTextSize(2); + spu.setTextColor( WHITE, BLUE ); + spu.printf(" %d \n", sgp.TVOC); + + spu.setCursor(93, 65, 4); spu.setTextSize(2); + spu.setTextColor( WHITE, BLUE ); + spu.printf(" %d \n", sgp.eCO2); + + spu.setTextColor( BLUE, CYAN); + spu.setCursor(10, 20, 4); spu.setTextSize(1); + spu.println("TVOC : "); + spu.setCursor(10, 80, 4); spu.setTextSize(1); + spu.println("eCO2 : "); + + spu.pushSprite(0, 0); // 画面に反映させる + + } else { + + spu.fillSprite( CYAN ); + spu.setCursor(93, 5, 4); spu.setTextSize(2); + spu.setTextColor( WHITE, BLUE ); + spu.printf(" %d \n", sgp.TVOC); + + spu.setCursor(93, 65, 4); spu.setTextSize(2); + spu.setTextColor( WHITE, BLUE ); + spu.printf(" %d \n", sgp.eCO2); + + spu.setTextColor( BLUE, CYAN); + spu.setCursor(10, 20, 4); spu.setTextSize(1); + spu.println("TVOC : "); + spu.setCursor(10, 80, 4); spu.setTextSize(1); + spu.println("eCO2 : "); - // eCO2が1000を超えたら音を鳴らす + + spu.pushSprite(0, 0); // 画面に反映させる + } + + + Serial.printf("TVOC: %d eCO2: %d\n", sgp.TVOC, sgp.eCO2); + // eCO2が1000を超えたら音を鳴らす if (sgp.eCO2 > 1000) { - spu.setCursor(10, 120, 4); spu.setTextSize(1); - spu.println("kankisite "); M5.Beep.setBeep(523, 500); M5.Beep.beep(); } M5.update(); + if (M5.Axp.GetBtnPress() == 2) { M5.Axp.Write1Byte(0x32, M5.Axp.Read8bit(0x32) | 0x80); // Power Off } - delay(500); + delay(1000); } + + void loop() { }