-
GUI (almost) done!
11/28/2020 at 16:13 • 0 commentsThis is the graphical interface I designed for the project.
It consists of primitive shapes and text using the TFT_eSPI library.
What do you think? -
Hello world! First connection (video + code)
07/04/2020 at 09:49 • 0 comments#include <Arduino.h> #include <TFT_eSPI.h> #include <SPI.h> #include <Wire.h> #include <Button2.h> #include "esp_adc_cal.h" //HID #include <BleMouse.h> #ifndef TFT_DISPOFF #define TFT_DISPOFF 0x28 #endif #ifndef TFT_SLPIN #define TFT_SLPIN 0x10 #endif #define TFT_MOSI 19 #define TFT_SCLK 18 #define TFT_BL 4 // Display backlight control pin #define ADC_EN 14 #define ADC_PIN 34 #define BUTTON_1 35 #define BUTTON_2 0 TFT_eSPI tft = TFT_eSPI(TFT_HEIGHT, TFT_WIDTH); // Invoke custom library //HID BleMouse bleMouse; boolean isConn = false; int touch_sensor_value_T0 =0; int touch_sensor_value_T1 =0; int tsv_ENTER =0; int tsv_SELECT =0; int tsv_CANCEL =0; int tsv_LEFT =0; int touch_sensor_value_T6 =0; int tsv_DOWN =0; int tsv_RIGHT =0; int touch_sensor_value_T9 =0; //! Long time delay, it is recommended to use shallow sleep, which can effectively reduce the current consumption void espDelay(int ms) { esp_sleep_enable_timer_wakeup(ms * 1000); esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH,ESP_PD_OPTION_ON); esp_light_sleep_start(); } void setup() { Serial.begin(9600); Serial.println("Start"); Serial.println("Starting BLE work!"); bleMouse.begin(); tft.init(); tft.setRotation(2); tft.fillScreen(TFT_BLACK); tft.setTextSize(2); tft.setTextColor(TFT_WHITE); tft.setCursor(0, 0); tft.setTextDatum(TL_DATUM); tft.drawString("Not connected", 70 , tft.height() / 2 ); if (TFT_BL > 0) { // TFT_BL has been set in the TFT_eSPI library in the User Setup file TTGO_T_Display.h pinMode(TFT_BL, OUTPUT); // Set backlight pin to output mode digitalWrite(TFT_BL, TFT_BACKLIGHT_ON); // Turn backlight on. TFT_BACKLIGHT_ON has been set in the TFT_eSPI library in the User Setup file TTGO_T_Display.h } espDelay(5000); } void loop() { tsv_ENTER = touchRead(T2); tsv_SELECT = touchRead(T3); tsv_CANCEL = touchRead(T4); tsv_LEFT = touchRead(T5); tsv_DOWN = touchRead(T7); tsv_RIGHT = touchRead(T8); //manca up!!! if( bleMouse.isConnected() && !isConn) { isConn = true; tft.fillScreen(TFT_BLACK); tft.drawString("Connected", 70 , tft.height() / 2 ); } else if(!bleMouse.isConnected() && isConn) { isConn = false; tft.fillScreen(TFT_BLACK); tft.drawString("Not connected", 70 , tft.height() / 2 ); } if (isConn) { if(tsv_LEFT > 5 && tsv_LEFT < 30){bleMouse.move(-2, 0, 0);} if(tsv_RIGHT > 5 && tsv_RIGHT < 30){bleMouse.move( 2, 0, 0);} if(tsv_DOWN > 5 && tsv_DOWN < 30){bleMouse.move( 0, 2, 0);} } delay(20); }
-
Modularity (test)
06/16/2020 at 09:03 • 0 comments