Skip to content

Commit

Permalink
WROVER tweaks.
Browse files Browse the repository at this point in the history
Had to move IR from pin 2 to 35. It works on pin2 in other code, but
there must be some conflict here that is preventing that.
  • Loading branch information
marcmerlin committed Apr 16, 2017
1 parent 4856857 commit c748512
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
5 changes: 3 additions & 2 deletions IoTuz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Adafruit_BME280 bme;
XPT2046_Touchscreen ts(TS_CS_PIN); // Param 2 - NULL - No interrupts)

IRrecv irrecv(IR_RX_PIN);
// Must be global to be passed to the IRRecord library.
decode_results IR_result;

// If enabled by the user, call every millisecond and run the Aiko
Expand Down Expand Up @@ -421,9 +422,9 @@ IoTuz::IoTuz()
pinMode(IR_RX_PIN, INPUT);
#ifndef WROVER
pinMode(IR_TX_PIN, OUTPUT);
pinMode(BAT_PIN, INPUT);
#endif

pinMode(BAT_PIN, INPUT);
}

void IoTuz::begin()
Expand Down Expand Up @@ -517,7 +518,7 @@ void IoTuz::begin()
attachInterrupt(ENCODERB_PIN, read_encoder_ISR, CHANGE);

Serial.println("Enable IR receiver ISR:");
// Sigh, enabling this hardware interrupt makes I2C unreliable.
// Sigh, enabling this hardware interrupt made I2C unreliable.
// Thankfully this HAL patch fixes the issue
// https://github.com/espressif/arduino-esp32/issues/286
irrecv.enableIRIn();
Expand Down
21 changes: 13 additions & 8 deletions IoTuz.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// This code can work somewhat on the WROVER board, you can comment this out:
#define WROVER
//#define WROVER

// MartyMacGyver/ESP32-Digital-RGB-LED-Drivers is better than the Adafruit
// Neopixel library. It flickers a bit, but if you want it, there you go:
Expand Down Expand Up @@ -151,16 +151,16 @@ BME280: 0x77 (Temp/Humidity/Pressure)
#define LCD_BL_CTR 5
#define TFT_CS 0

// Do not use pin 12, this blocks the board. Likely avoid 13/14 too (SPI)
// 32, 33, 34 do not work either for IO input,
//
// You can plug a neopixel here:
#define RGB_LED_PIN 0

// Infrared is not needed either, but works for me.
// You would have to enter your own hex codes in IRcodes.h
#define IR_RX_PIN 2
#define IR_RX_PIN 35

// Do not use pin 12, this blocks the board. Likely avoid 13/14 too (SPI)
// 32, 33, 34 do not seem to work either for IO input,
// joystick is recommended to play the games
#define JOYSTICK_BUT_PIN 27
#define JOYSTICK_X_PIN 39
Expand All @@ -170,12 +170,17 @@ BME280: 0x77 (Temp/Humidity/Pressure)
#define ENCODERB_PIN 26
#define ENCODER_BUT_PIN 15

// My WROVER board uses a ST7789V instead of ILI9341, the TFT init returns this:
// ILI9341 Test!
// Display Power Mode: 0x9C
// MADCTL Mode: 0x48
// Pixel Format: 0x5
// Display Power Mode: 0xCE
// MADCTL Mode: 0x0
// Pixel Format: 0x2
// Image Format: 0x0
// Self Diagnostic: 0xC0
// Self Diagnostic: 0xE0
// Resolution: 320 x 240

// ILI driver works on rover boards with an ILI chip, but newer boards use ST7789V
// so use the WROVER driver that handles both.
extern WROVER_KIT_LCD tft;
#else
extern Adafruit_ILI9341 tft;
Expand Down
4 changes: 4 additions & 0 deletions examples/fulldemo/fulldemo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -776,15 +776,19 @@ void LCD_PWM_Handler() {
}

void Battery_Handler() {
#ifndef WROVER
if (DISABLE_OVERLAY_TEXT) return;
sprintf(iotuz.tft_str, "Bat:%4.2fV", iotuz.battery_level());
iotuz.tftprint(44, 29, 9, iotuz.tft_str);
#endif
}

void HumiTemp_Handler() {
#ifndef WROVER
if (DISABLE_OVERLAY_TEXT) return;
sprintf(iotuz.tft_str, "%5.2fC hum:%2d%%", bme.readTemperature(), (int)bme.readHumidity());
iotuz.tftprint(0, 29, 14, iotuz.tft_str);
#endif
}

void loop() {
Expand Down

0 comments on commit c748512

Please sign in to comment.