-
Notifications
You must be signed in to change notification settings - Fork 0
/
trashVNC.ino
163 lines (122 loc) · 3.49 KB
/
trashVNC.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#include <ESP8266WiFi.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_NeoPixel.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BNO055.h>
#include <utility/imumaths.h>
#include <IRremoteESP8266.h>
#include <TFT_ILI9163C.h>
#include <ESPAsyncUDP.h>
#include "rboot-api.h"
#include <FS.h>
// WIP need to undefine the framebuffer to have the pixelflutserver running
#define BNO055_SAMPLERATE_DELAY_MS (10)
#define VERSION 2
#define USEWIFI
//#define USEIR
#define GPIO_LCD_DC 0
#define GPIO_TX 1
#define GPIO_WS2813 4
#define GPIO_RX 3
#define GPIO_DN 2
#define GPIO_DP 5
#define GPIO_BOOT 16
#define GPIO_MOSI 13
#define GPIO_CLK 14
#define GPIO_LCD_CS 15
#define GPIO_BNO 12
#define MUX_JOY 0
#define MUX_BAT 1
#define MUX_LDR 2
#define MUX_ALK 4
#define MUX_IN1 5
#define VIBRATOR 3
#define MQ3_EN 4
#define LCD_LED 5
#define IR_EN 6
#define OUT1 7
#define UP 720
#define DOWN 570
#define RIGHT 480
#define LEFT 960
#define OFFSET 50
#define I2C_PCA 0x25
#define NUM_LEDS 4
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
TFT_ILI9163C tft = TFT_ILI9163C(GPIO_LCD_CS, GPIO_LCD_DC);
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUM_LEDS, GPIO_WS2813, NEO_GRB + NEO_KHZ800);
Adafruit_BNO055 bno = Adafruit_BNO055(BNO055_ID, BNO055_ADDRESS_B);
byte portExpanderConfig = 0; //stores the 74HC595 config
void setup() {
initBadge();
WiFi.disconnect();
delay(100);
WiFi.mode(WIFI_AP_STA);
WiFi.softAPConfig(IPAddress (10, 0, 0, 1), IPAddress(10, 0, 0, 1), IPAddress(255, 255, 255, 0));
char ssid[20];
sprintf(ssid, "mn-%d", ESP.getChipId());
WiFi.softAP(ssid);
tft.setTextSize(1);
tft.println("");
tft.println("");
tft.println("");
tft.println("read goo.gl/ApwhQo");
tft.println("");
tft.println("");
tft.println("and connect to: ");
tft.setTextSize(3);
tft.println(ssid);
tft.setTextSize(1);
tft.writeFramebuffer();
rboot_config rboot_config = rboot_get_config();
Serial.print("I am in Slot ");
Serial.println(rboot_config.current_rom);
SPIFFS.begin();
File f = SPIFFS.open("/rom" + String(rboot_config.current_rom), "w");
f.println("trashVNC\n");
init_upd_video(fbuff);
}
void loop() {
}
void setGPIO(byte channel, boolean level) {
bitWrite(portExpanderConfig, channel, level);
Wire.beginTransmission(I2C_PCA);
Wire.write(portExpanderConfig);
Wire.endTransmission();
}
void setAnalogMUX(byte channel) {
portExpanderConfig = portExpanderConfig & 0b11111000;
portExpanderConfig = portExpanderConfig | channel;
Wire.beginTransmission(I2C_PCA);
Wire.write(portExpanderConfig);
Wire.endTransmission();
}
void initBadge() { //initialize the badge
Serial.begin(115200);
pinMode(GPIO_BOOT, INPUT_PULLDOWN_16); // settings for the leds
pinMode(GPIO_WS2813, OUTPUT);
pixels.begin(); //initialize the WS2813
pixels.clear();
pixels.show();
Wire.begin(9, 10); // Initalize i2c bus
Wire.beginTransmission(I2C_PCA);
Wire.write(0b00000000); //...clear the I2C extender to switch off vibrator and backlight
Wire.endTransmission();
delay(100);
tft.begin(); //initialize the tft. This also sets up SPI to 80MHz Mode 0
tft.setRotation(2); //turn screen
tft.scroll(32); //move down by 32 pixels (needed)
tft.fillScreen(BLACK); //make screen black
tft.writeFramebuffer();
setGPIO(LCD_LED, HIGH);
setAnalogMUX(0);
}