Englebert
3 years ago
commit
2b17228c27
1 changed files with 87 additions and 0 deletions
@ -0,0 +1,87 @@ |
|||
#include <ESP_8_BIT_GFX.h>
|
|||
|
|||
// 8-bits color code
|
|||
// RRRGGGBB
|
|||
|
|||
// Create an instance of the graphics library
|
|||
ESP_8_BIT_GFX video(false /* = NTSC */, 8 /* = RGB332 color */); |
|||
|
|||
#define TOUCH_MODE T9
|
|||
const int VALUE_THRESHOLD = 10; |
|||
int touched_val = 0; |
|||
bool touched = false; |
|||
uint32_t last_touched = 0; |
|||
|
|||
hw_timer_t * timer = NULL; /* create a hardware timer */ |
|||
uint8_t c = 0; |
|||
uint8_t color = 0; |
|||
|
|||
void display_output() { |
|||
// Wait for the next frame to minimize chance of visible tearing
|
|||
video.waitForFrame(); |
|||
|
|||
// Clear screen
|
|||
video.fillScreen(0); |
|||
|
|||
video.setCursor(26,3); |
|||
video.setTextColor(0b00011100); |
|||
video.setTextSize(2); |
|||
video.setTextWrap(true); |
|||
// video.fillRect(0,0,100,10,0xff);
|
|||
// void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color) override;
|
|||
video.print("BertFPV Diversity"); |
|||
|
|||
color = 0b10010010; |
|||
video.drawFastHLine(0, 0, 255, color); |
|||
video.drawFastHLine(0, 20, 255, color); |
|||
video.drawFastVLine(0, 0, 20, color); |
|||
video.drawFastVLine(255, 0, 20, color); |
|||
|
|||
video.setCursor(0, 30); |
|||
video.setTextColor(0xFF); |
|||
video.setTextSize(1); |
|||
video.print("Color:"); |
|||
video.print(String(c)); |
|||
|
|||
video.setCursor(0, 40); |
|||
video.setTextColor(0xFF); |
|||
video.setTextSize(1); |
|||
video.print("Touch:"); |
|||
video.print(touched_val); |
|||
} |
|||
|
|||
void IRAM_ATTR onTimer(){ |
|||
if(!touched) |
|||
c++; |
|||
} |
|||
|
|||
void setup() { |
|||
// Preparing Timer Hardware
|
|||
/* 1 Aick take 1/(80MHZ/80) = 1us so we set divider 80 and count up */ |
|||
timer = timerBegin(0, 80, true); |
|||
|
|||
/* Attach onTimer function to our timer */ |
|||
timerAttachInterrupt(timer, &onTimer, true); |
|||
|
|||
/* Set alarm to call onTimer function every second 1 tick is 1us => 1 second is 1000000us */ |
|||
/* Repeat the alarm (third parameter) */ |
|||
// timerAlarmWrite(timer, 1000000, true);
|
|||
timerAlarmWrite(timer, 100000, true); |
|||
|
|||
/* Start an alarm */ |
|||
timerAlarmEnable(timer); |
|||
|
|||
video.begin(); |
|||
} |
|||
|
|||
void loop() { |
|||
display_output(); |
|||
|
|||
touched_val = touchRead(TOUCH_MODE); |
|||
if(touched_val < VALUE_THRESHOLD) { |
|||
if(millis() > last_touched) { |
|||
touched = !touched; |
|||
last_touched = millis() + 500; |
|||
} |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue