Skip to content

Commit af5e6d0

Browse files
committed
Init
1 parent 556f42a commit af5e6d0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+7209
-0
lines changed

.editorconfig

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# This file is for unifying the coding style for different editors and IDEs
2+
# editorconfig.org
3+
4+
root = true
5+
6+
[*]
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
indent_style = space
12+
indent_size = 2
13+
max_line_length = 100
14+
curly_bracket_next_line = false
15+
16+
[*.{html,php}]
17+
max_line_length = 160

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.pio
2+
.vscode/.browse.c_cpp.db*
3+
.vscode/c_cpp_properties.json
4+
.vscode/launch.json
5+
.vscode/ipch

.vscode/extensions.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
// See http://go.microsoft.com/fwlink/?LinkId=827846
3+
// for the documentation about the extensions.json format
4+
"recommendations": [
5+
"platformio.platformio-ide"
6+
],
7+
"unwantedRecommendations": [
8+
"ms-vscode.cpptools-extension-pack"
9+
]
10+
}

.vscode/settings.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"files.associations": {
3+
"functional": "cpp",
4+
"tuple": "cpp"
5+
}
6+
}

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Color Kit Grande Weather Station
2+
3+
Weather station application for the ThingPulse Color Kit Grande.

data/ThingPulse-logo-260.jpeg

24.9 KB
Loading

data/moon/moonphase_L0.bmp

10.7 KB
Binary file not shown.

data/moon/moonphase_L1.bmp

10.7 KB
Binary file not shown.

data/moon/moonphase_L10.bmp

10.7 KB
Binary file not shown.

data/moon/moonphase_L11.bmp

10.7 KB
Binary file not shown.

data/moon/moonphase_L12.bmp

10.7 KB
Binary file not shown.

data/moon/moonphase_L13.bmp

10.7 KB
Binary file not shown.

data/moon/moonphase_L14.bmp

10.7 KB
Binary file not shown.

data/moon/moonphase_L15.bmp

10.7 KB
Binary file not shown.

data/moon/moonphase_L16.bmp

10.7 KB
Binary file not shown.

data/moon/moonphase_L17.bmp

10.7 KB
Binary file not shown.

data/moon/moonphase_L18.bmp

10.7 KB
Binary file not shown.

data/moon/moonphase_L19.bmp

10.7 KB
Binary file not shown.

data/moon/moonphase_L2.bmp

10.7 KB
Binary file not shown.

data/moon/moonphase_L20.bmp

10.7 KB
Binary file not shown.

data/moon/moonphase_L21.bmp

10.7 KB
Binary file not shown.

data/moon/moonphase_L22.bmp

10.7 KB
Binary file not shown.

data/moon/moonphase_L23.bmp

10.7 KB
Binary file not shown.

data/moon/moonphase_L3.bmp

10.7 KB
Binary file not shown.

data/moon/moonphase_L4.bmp

10.7 KB
Binary file not shown.

data/moon/moonphase_L5.bmp

10.7 KB
Binary file not shown.

data/moon/moonphase_L6.bmp

10.7 KB
Binary file not shown.

data/moon/moonphase_L7.bmp

10.7 KB
Binary file not shown.

data/moon/moonphase_L8.bmp

10.7 KB
Binary file not shown.

data/moon/moonphase_L9.bmp

10.7 KB
Binary file not shown.

include/README

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
This directory is intended for project header files.
3+
4+
A header file is a file containing C declarations and macro definitions
5+
to be shared between several project source files. You request the use of a
6+
header file in your project source file (C, C++, etc) located in `src` folder
7+
by including it, with the C preprocessing directive `#include'.
8+
9+
```src/main.c
10+
11+
#include "header.h"
12+
13+
int main (void)
14+
{
15+
...
16+
}
17+
```
18+
19+
Including a header file produces the same results as copying the header file
20+
into each source file that needs it. Such copying would be time-consuming
21+
and error-prone. With a header file, the related declarations appear
22+
in only one place. If they need to be changed, they can be changed in one
23+
place, and programs that include the header file will automatically use the
24+
new version when next recompiled. The header file eliminates the labor of
25+
finding and changing all the copies as well as the risk that a failure to
26+
find one copy will result in inconsistencies within a program.
27+
28+
In C, the usual convention is to give header files names that end with `.h'.
29+
It is most portable to use only letters, digits, dashes, and underscores in
30+
header file names, and at most one dot.
31+
32+
Read more about using header files in official GCC documentation:
33+
34+
* Include Syntax
35+
* Include Operation
36+
* Once-Only Headers
37+
* Computed Includes
38+
39+
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html

lib/README

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
This directory is intended for project specific (private) libraries.
3+
PlatformIO will compile them to static libraries and link into executable file.
4+
5+
The source code of each library should be placed in a an own separate directory
6+
("lib/your_library_name/[here are source files]").
7+
8+
For example, see a structure of the following two libraries `Foo` and `Bar`:
9+
10+
|--lib
11+
| |
12+
| |--Bar
13+
| | |--docs
14+
| | |--examples
15+
| | |--src
16+
| | |- Bar.c
17+
| | |- Bar.h
18+
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
19+
| |
20+
| |--Foo
21+
| | |- Foo.c
22+
| | |- Foo.h
23+
| |
24+
| |- README --> THIS FILE
25+
|
26+
|- platformio.ini
27+
|--src
28+
|- main.c
29+
30+
and a contents of `src/main.c`:
31+
```
32+
#include <Foo.h>
33+
#include <Bar.h>
34+
35+
int main (void)
36+
{
37+
...
38+
}
39+
40+
```
41+
42+
PlatformIO Library Dependency Finder will find automatically dependent
43+
libraries scanning project source files.
44+
45+
More information about PlatformIO Library Dependency Finder
46+
- https://docs.platformio.org/page/librarymanager/ldf.html

platformio.ini

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
; PlatformIO Project Configuration File for ThingPulse Color Kit Grande
2+
;
3+
; Documentation: https://docs.thingpulse.com/guides/esp32-color-kit-grande/
4+
;
5+
; Additional PlatformIO options and examples: https://docs.platformio.org/page/projectconf.html
6+
7+
[env:thingpulse-color-kit-grande]
8+
platform = espressif32@~6.1.0
9+
board = esp-wrover-kit
10+
framework = arduino
11+
; Adjust port and speed to your system and its capabilities e.g. "upload_port = COM3" on Windows.
12+
; To list all availble ports you may also run 'pio device list' in the Visual Studio Code terminal window.
13+
upload_port = /dev/tty.wchusbserial54790238451
14+
monitor_port = /dev/tty.wchusbserial54790238451
15+
monitor_speed = 115200
16+
; For your OS & driver combination you might have to lower this to 921600 or even 460800.
17+
upload_speed = 1500000
18+
monitor_filters = esp32_exception_decoder, time
19+
build_flags =
20+
; core flags
21+
-DCORE_DEBUG_LEVEL=3
22+
-DBOARD_HAS_PSRAM
23+
-mfix-esp32-psram-cache-issue
24+
; TFT_eSPI flags
25+
; Below we replicate the flags from TFT_eSPI/User_Setups/Setup21_ILI9488.h.
26+
; You can't mix'n match from their .h and -D here.
27+
-D USER_SETUP_LOADED=1 # 1 => will not load User_Setup.h from TFT_eSPI but rely on the flags defined here
28+
-D ILI9488_DRIVER=1
29+
-D TFT_MISO=19
30+
-D TFT_MOSI=18
31+
-D TFT_SCLK=05
32+
-D TFT_CS=15
33+
-D TFT_DC=2
34+
-D TFT_RST=4
35+
-D TFT_BL=32
36+
; As we're using OpenFontRender we don't need any of the TFT_eSPI built-in fonts.
37+
; Font descriptions at TFT_eSPI/User_Setups/Setup21_ILI9488.h
38+
-D LOAD_GLCD=0
39+
-D LOAD_FONT2=0
40+
-D LOAD_FONT4=0
41+
-D LOAD_FONT6=0
42+
-D LOAD_FONT7=0
43+
-D LOAD_FONT8=0
44+
-D LOAD_GFXFF=0
45+
-D SMOOTH_FONT=1
46+
-D SPI_FREQUENCY=27000000
47+
; required if you include OpenFontRender and build on macOS
48+
-I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/**
49+
board_build.partitions = no_ota.csv
50+
board_build.filesystem = littlefs
51+
lib_deps =
52+
bodmer/TFT_eSPI@~2.5.30
53+
bodmer/TJpg_Decoder@~1.0.8
54+
https://github.com/Bodmer/OpenFontRender#96a29bc ; no tags or releases to reference :( -> pin to Git revision

src/FT6236.cpp

+211
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
/*
2+
* - ThingPulse -
3+
* This version taken from https://github.com/DustinWatts/FT6236/pull/9
4+
* To be removed as soon as the new version at https://github.com/DustinWatts/FocalTech_Touch is released and available in the PIO registry.
5+
*/
6+
7+
8+
/*
9+
This is a library for the FT6236 touchscreen controller by FocalTech.
10+
11+
The FT6236 and FT6236u work the same way.
12+
13+
A lot of this library is originally written by Limor Fried/Ladyada.
14+
15+
Because Adafruit invests time and resources providing this open source code,
16+
please support Adafruit and open-source hardware by purchasing
17+
products from Adafruit!
18+
19+
@section author Author
20+
Written by Limor Fried/Ladyada for Adafruit Industries.
21+
22+
@section license License
23+
MIT license, all text above must be included in any redistribution
24+
*/
25+
26+
#include "Arduino.h"
27+
#include "FT6236.h"
28+
#include <Wire.h>
29+
30+
/* New class. */
31+
FT6236::FT6236(uint16_t width, uint16_t height)
32+
{
33+
touches = 0;
34+
_touch_width = width;
35+
_touch_height = height;
36+
}
37+
38+
/* Start I2C and check if the FT6236 is found. */
39+
boolean FT6236::begin(uint8_t thresh, int8_t sda, int8_t scl)
40+
{
41+
if (sda != -1 && scl != -1)
42+
{
43+
Wire.begin(sda, scl);
44+
}
45+
else
46+
{
47+
Wire.begin();
48+
}
49+
50+
// Adjust threshold
51+
writeRegister8(FT6236_REG_THRESHHOLD, thresh);
52+
53+
// Check if our chip has the correct Vendor ID
54+
uint8_t id = readRegister8(FT6236_REG_VENDID);
55+
if ((id != FT6236_VENDID) && (id != FT5436_VENDID))
56+
{
57+
return false;
58+
}
59+
// Check if our chip has the correct Chip ID.
60+
id = readRegister8(FT6236_REG_CHIPID);
61+
if ((id != FT6236_CHIPID) && (id != FT6236U_CHIPID) &&
62+
(id != FT6206_CHIPID) && (id != FT5436_CHIPID))
63+
{
64+
return false;
65+
}
66+
67+
return true;
68+
}
69+
70+
void FT6236::setRotation(uint8_t rotation)
71+
{
72+
_rotation = rotation;
73+
}
74+
75+
/* Returns the number of touches */
76+
uint8_t FT6236::touched(void)
77+
{
78+
uint8_t n = readRegister8(FT6236_REG_NUMTOUCHES);
79+
if (n > 2)
80+
{
81+
n = 0;
82+
}
83+
return n;
84+
}
85+
86+
/* Get a touch point */
87+
TS_Point FT6236::getPoint(uint8_t n)
88+
{
89+
readData();
90+
if ((touches == 0) || (n > 1))
91+
{
92+
return TS_Point(0, 0, 0, _touch_width, _touch_height, _rotation);
93+
}
94+
else
95+
{
96+
return TS_Point(touchX[n], touchY[n], 1, _touch_width, _touch_height, _rotation);
97+
}
98+
}
99+
100+
void FT6236::readData(void)
101+
{
102+
103+
uint8_t i2cdat[16];
104+
Wire.beginTransmission(FT6236_ADDR);
105+
Wire.write((byte)0);
106+
Wire.endTransmission();
107+
108+
Wire.requestFrom((byte)FT6236_ADDR, (byte)16);
109+
for (uint8_t i = 0; i < 16; i++)
110+
i2cdat[i] = Wire.read();
111+
112+
touches = i2cdat[0x02];
113+
if ((touches > 2) || (touches == 0))
114+
{
115+
touches = 0;
116+
}
117+
118+
for (uint8_t i = 0; i < 2; i++)
119+
{
120+
touchX[i] = i2cdat[0x03 + i * 6] & 0x0F;
121+
touchX[i] <<= 8;
122+
touchX[i] |= i2cdat[0x04 + i * 6];
123+
touchY[i] = i2cdat[0x05 + i * 6] & 0x0F;
124+
touchY[i] <<= 8;
125+
touchY[i] |= i2cdat[0x06 + i * 6];
126+
touchID[i] = i2cdat[0x05 + i * 6] >> 4;
127+
}
128+
}
129+
130+
/* Reading a byte from a register */
131+
uint8_t FT6236::readRegister8(uint8_t reg)
132+
{
133+
uint8_t x;
134+
135+
Wire.beginTransmission(FT6236_ADDR);
136+
Wire.write((byte)reg);
137+
Wire.endTransmission();
138+
139+
Wire.requestFrom((byte)FT6236_ADDR, (byte)1);
140+
x = Wire.read();
141+
142+
return x;
143+
}
144+
145+
/* Writing a byte to a register */
146+
void FT6236::writeRegister8(uint8_t reg, uint8_t val)
147+
{
148+
149+
Wire.beginTransmission(FT6236_ADDR);
150+
Wire.write((byte)reg);
151+
Wire.write((byte)val);
152+
Wire.endTransmission();
153+
}
154+
155+
/* Debug */
156+
void FT6236::debug(void)
157+
{
158+
Serial.print("Vend ID: 0x");
159+
Serial.println(readRegister8(FT6236_REG_VENDID), HEX);
160+
Serial.print("Chip ID: 0x");
161+
Serial.println(readRegister8(FT6236_REG_CHIPID), HEX);
162+
Serial.print("Firm V: ");
163+
Serial.println(readRegister8(FT6236_REG_FIRMVERS));
164+
Serial.print("Point Rate Hz: ");
165+
Serial.println(readRegister8(FT6236_REG_POINTRATE));
166+
Serial.print("Thresh: ");
167+
Serial.println(readRegister8(FT6236_REG_THRESHHOLD));
168+
}
169+
170+
TS_Point::TS_Point(void) { x = y = z = 0; }
171+
172+
TS_Point::TS_Point(int16_t _x, int16_t _y, int16_t _z, uint16_t width, uint16_t height, uint8_t rotation)
173+
{
174+
uint16_t t;
175+
switch (rotation)
176+
{
177+
case 0:
178+
_x = height - _x;
179+
_y = width - _y;
180+
break;
181+
case 1:
182+
t = _x;
183+
_x = _y;
184+
_y = t;
185+
_x = width - _x;
186+
break;
187+
case 2:
188+
break;
189+
case 3:
190+
t = _x;
191+
_x = _y;
192+
_y = t;
193+
_y = height - _y;
194+
break;
195+
}
196+
x = _x;
197+
y = _y;
198+
z = _z;
199+
}
200+
201+
/* == comparator between two points */
202+
bool TS_Point::operator==(TS_Point p1)
203+
{
204+
return ((p1.x == x) && (p1.y == y) && (p1.z == z));
205+
}
206+
207+
/* != comparator netween two points */
208+
bool TS_Point::operator!=(TS_Point p1)
209+
{
210+
return ((p1.x != x) || (p1.y != y) || (p1.z != z));
211+
}

0 commit comments

Comments
 (0)