honey_the_codewitch

ttgo barebones

Jan 8th, 2023
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.04 KB | None | 0 0
  1. #include <ttgo.hpp>
  2. // downloaded from fontsquirrel.com and header generated with
  3. // https://honeythecodewitch.com/gfx/generator
  4. #include <fonts/Telegrama.hpp>
  5. static void button_a_on_click(int clicks,void* state) {
  6.     // reset the dimmer
  7.     dimmer.wake();
  8. }
  9. static void button_b_on_click(int clicks,void* state) {
  10.     // reset the dimmer
  11.     dimmer.wake();
  12. }
  13. void setup() {
  14.     Serial.begin(115200);
  15.     ttgo_initialize();
  16.     lcd.rotation(1);
  17.     // set the button callbacks
  18.     button_a.on_click(button_a_on_click);
  19.     button_b.on_click(button_b_on_click);
  20.    
  21.     draw::filled_rectangle(lcd,lcd.bounds(),color_t::purple);
  22.     open_text_info oti;
  23.     oti.font = &Telegrama;
  24.     oti.text = "TTGO T1";
  25.     oti.scale = oti.font->scale(35);
  26.     oti.transparent_background = false;
  27.     srect16 txtr = oti.font->measure_text(ssize16::max(),spoint16::zero(),oti.text,oti.scale).bounds();
  28.     txtr.center_inplace((srect16)lcd.bounds());
  29.     draw::text(lcd,txtr,oti,color_t::white,color_t::purple);
  30. }
  31.  
  32. void loop() {
  33.     ttgo_update();
  34. }
Add Comment
Please, Sign In to add comment