1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-29 05:21:37 +03:00

Migrate from astyle to clang-format (#8464)

This commit is contained in:
Maxim Prokhorov
2022-02-20 19:23:33 +03:00
committed by Max Prokhorov
parent 46190b61f1
commit 19b7a29720
241 changed files with 15925 additions and 16197 deletions

View File

@ -8,22 +8,20 @@
#include <SPI.h>
void setup() {
TFT_BL_ON; //turn on the background light
TFT_BL_ON; // turn on the background light
Tft.TFTinit(); //init TFT library
Tft.TFTinit(); // init TFT library
Tft.drawCircle(100, 100, 30, YELLOW); //center: (100, 100), r = 30 ,color : YELLOW
Tft.drawCircle(100, 100, 30, YELLOW); // center: (100, 100), r = 30 ,color : YELLOW
Tft.drawCircle(100, 200, 40, CYAN); // center: (100, 200), r = 10 ,color : CYAN
Tft.drawCircle(100, 200, 40, CYAN); // center: (100, 200), r = 10 ,color : CYAN
Tft.fillCircle(200, 100, 30, RED); //center: (200, 100), r = 30 ,color : RED
Tft.fillCircle(200, 100, 30, RED); // center: (200, 100), r = 30 ,color : RED
Tft.fillCircle(200, 200, 30, BLUE); //center: (200, 200), r = 30 ,color : BLUE
Tft.fillCircle(200, 200, 30, BLUE); // center: (200, 200), r = 30 ,color : BLUE
}
void loop() {
}
void loop() {}
/*********************************************************************************************************
END FILE

View File

@ -8,21 +8,19 @@
#include <TFTv2.h>
#include <SPI.h>
void setup() {
TFT_BL_ON; // turn on the background light
Tft.TFTinit(); //init TFT library
TFT_BL_ON; // turn on the background light
Tft.TFTinit(); // init TFT library
Tft.drawLine(0, 0, 239, 319, RED); //start: (0, 0) end: (239, 319), color : RED
Tft.drawLine(0, 0, 239, 319, RED); // start: (0, 0) end: (239, 319), color : RED
Tft.drawVerticalLine(60, 100, 100, GREEN); // Draw a vertical line
// start: (60, 100) length: 100 color: green
Tft.drawHorizontalLine(30, 60, 150, BLUE); //Draw a horizontal line
//start: (30, 60), high: 150, color: blue
Tft.drawHorizontalLine(30, 60, 150, BLUE); // Draw a horizontal line
// start: (30, 60), high: 150, color: blue
}
void loop() {
}
void loop() {}
/*********************************************************************************************************
END FILE

View File

@ -9,29 +9,26 @@
#include <SPI.h>
void setup() {
TFT_BL_ON; // turn on the background light
TFT_BL_ON; // turn on the background light
Tft.TFTinit(); // init TFT library
Tft.TFTinit(); // init TFT library
Tft.drawNumber(1024, 0, 0, 1, RED); // draw a integer: 1024, Location: (0, 0), size: 1, color: RED
Tft.drawNumber(1024, 0, 0, 1, RED); // draw a integer: 1024, Location: (0, 0), size: 1, color: RED
Tft.drawNumber(1024, 0, 20, 2, BLUE); // draw a integer: 1024, Location: (0, 20), size: 2, color: BLUE
Tft.drawNumber(1024, 0, 20, 2, BLUE); // draw a integer: 1024, Location: (0, 20), size: 2, color: BLUE
Tft.drawNumber(1024, 0, 50, 3, GREEN); // draw a integer: 1024, Location: (0, 50), size: 3, color: GREEN
Tft.drawNumber(1024, 0, 50, 3, GREEN); // draw a integer: 1024, Location: (0, 50), size: 3, color: GREEN
Tft.drawNumber(1024, 0, 90, 4, BLUE); // draw a integer: 1024, Location: (0, 90), size:4, color: BLUE
Tft.drawNumber(1024, 0, 90, 4, BLUE); // draw a integer: 1024, Location: (0, 90), size:4, color: BLUE
Tft.drawFloat(1.2345, 0, 150, 4, YELLOW); // draw a float number: 1.2345, Location: (0, 150), size: 4, color: YELLOW
Tft.drawFloat(1.2345, 0, 150, 4, YELLOW); // draw a float number: 1.2345, Location: (0, 150), size: 4, color: YELLOW
Tft.drawFloat(1.2345, 2, 0, 200, 4, BLUE); // draw a float number: 1.2345: Location: (0, 200), size: 4, decimal: 2, color: BLUE
Tft.drawFloat(1.2345, 4, 0, 250, 4, RED); // draw a float number: 1.2345 Location: (0, 250), size: 4, decimal: 4, color: RED
Tft.drawFloat(1.2345, 2, 0, 200, 4, BLUE); // draw a float number: 1.2345: Location: (0, 200), size: 4, decimal: 2, color: BLUE
Tft.drawFloat(1.2345, 4, 0, 250, 4, RED); // draw a float number: 1.2345 Location: (0, 250), size: 4, decimal: 4, color: RED
}
void loop() {
}
void loop() {}
/*********************************************************************************************************
END FILE

View File

@ -16,9 +16,7 @@ void setup() {
Tft.drawRectangle(100, 170, 120, 60, BLUE);
}
void loop() {
}
void loop() {}
/*********************************************************************************************************
END FILE
*********************************************************************************************************/

View File

@ -5,29 +5,27 @@
#include <SPI.h>
int ColorPaletteHigh = 30;
int color = WHITE; //Paint brush color
unsigned int colors[8] = {BLACK, RED, GREEN, BLUE, CYAN, YELLOW, WHITE, GRAY1};
int color = WHITE; // Paint brush color
unsigned int colors[8] = { BLACK, RED, GREEN, BLUE, CYAN, YELLOW, WHITE, GRAY1 };
// For better pressure precision, we need to know the resistance
// between X+ and X- Use any multimeter to read it
// The 2.8" TFT Touch shield has 300 ohms across the X plate
TouchScreen ts = TouchScreen(XP, YP, XM, YM); //init TouchScreen port pins
TouchScreen ts = TouchScreen(XP, YP, XM, YM); // init TouchScreen port pins
void setup() {
Tft.TFTinit(); //init TFT library
Tft.TFTinit(); // init TFT library
Serial.begin(115200);
//Draw the pallet
for (int i = 0; i < 8; i++) {
Tft.fillRectangle(i * 30, 0, 30, ColorPaletteHigh, colors[i]);
}
// Draw the pallet
for (int i = 0; i < 8; i++) { Tft.fillRectangle(i * 30, 0, 30, ColorPaletteHigh, colors[i]); }
}
void loop() {
// a point object holds x y and z coordinates.
Point p = ts.getPoint();
//map the ADC value read to into pixel coordinates
// map the ADC value read to into pixel coordinates
p.x = map(p.x, TS_MINX, TS_MAXX, 0, 240);
p.y = map(p.y, TS_MINY, TS_MAXY, 0, 320);

View File

@ -5,13 +5,13 @@
#include <SPI.h>
void setup() {
TFT_BL_ON; // turn on the background light
Tft.TFTinit(); // init TFT library
TFT_BL_ON; // turn on the background light
Tft.TFTinit(); // init TFT library
}
void loop() {
for (int r = 0; r < 115; r = r + 2) { //set r : 0--115
Tft.drawCircle(119, 160, r, random(0xFFFF)); //draw circle, center:(119, 160), color: random
for (int r = 0; r < 115; r = r + 2) { // set r : 0--115
Tft.drawCircle(119, 160, r, random(0xFFFF)); // draw circle, center:(119, 160), color: random
}
delay(10);
}

View File

@ -11,23 +11,19 @@ void setup() {
TFT_BL_ON; // turn on the background light
Tft.TFTinit(); // init TFT library
Tft.drawChar('S', 0, 0, 1, RED); // draw char: 'S', (0, 0), size: 1, color: RED
Tft.drawChar('S', 0, 0, 1, RED); // draw char: 'S', (0, 0), size: 1, color: RED
Tft.drawChar('E', 10, 10, 2, BLUE); // draw char: 'E', (10, 10), size: 2, color: BLUE
Tft.drawChar('E', 10, 10, 2, BLUE); // draw char: 'E', (10, 10), size: 2, color: BLUE
Tft.drawChar('E', 20, 40, 3, GREEN); // draw char: 'E', (20, 40), size: 3, color: GREEN
Tft.drawChar('E', 20, 40, 3, GREEN); // draw char: 'E', (20, 40), size: 3, color: GREEN
Tft.drawChar('E', 30, 80, 4, YELLOW); // draw char: 'E', (30, 80), size: 4, color: YELLOW
Tft.drawChar('E', 30, 80, 4, YELLOW); // draw char: 'E', (30, 80), size: 4, color: YELLOW
Tft.drawChar('D', 40, 120, 4, YELLOW); // draw char: 'D', (40, 120), size: 4, color: YELLOW
Tft.drawString("Hello", 0, 180, 3, CYAN); // draw string: "hello", (0, 180), size: 3, color: CYAN
Tft.drawString("World!!", 60, 220, 4, WHITE); // draw string: "world!!", (80, 230), size: 4, color: WHITE
Tft.drawChar('D', 40, 120, 4, YELLOW); // draw char: 'D', (40, 120), size: 4, color: YELLOW
Tft.drawString("Hello", 0, 180, 3, CYAN); // draw string: "hello", (0, 180), size: 3, color: CYAN
Tft.drawString("World!!", 60, 220, 4, WHITE); // draw string: "world!!", (80, 230), size: 4, color: WHITE
}
void loop() {
}
void loop() {}

View File

@ -16,21 +16,22 @@
#include "TFTv2.h"
#define MAX_BMP 10 // bmp file num
#define FILENAME_LEN 20 // max file name length
#define MAX_BMP 10 // bmp file num
#define FILENAME_LEN 20 // max file name length
const int PIN_SD_CS = 4; // pin of sd card
const int PIN_SD_CS = 4; // pin of sd card
const int __Gnbmp_height = 320; // bmp height
const int __Gnbmp_width = 240; // bmp width
const int __Gnbmp_height = 320; // bmp height
const int __Gnbmp_width = 240; // bmp width
unsigned char __Gnbmp_image_offset = 0; // offset
unsigned char __Gnbmp_image_offset = 0; // offset
int __Gnfile_num = 3; // num of file
int __Gnfile_num = 3; // num of file
char __Gsbmp_files[3][FILENAME_LEN] = { // add file name here
char __Gsbmp_files[3][FILENAME_LEN] = {
// add file name here
"flower.BMP",
"hibiscus.bmp",
"test.bmp",
@ -54,7 +55,8 @@ void setup() {
if (!SD.begin(PIN_SD_CS)) {
Serial.println("failed!");
while (1); // init fail, die here
while (1)
; // init fail, die here
}
Serial.println("SD OK!");
@ -65,12 +67,13 @@ void setup() {
void loop() {
for (unsigned char i = 0; i < __Gnfile_num; i++) {
bmpFile = SD.open(__Gsbmp_files[i]);
if (! bmpFile) {
if (!bmpFile) {
Serial.println("didn't find image");
while (1);
while (1)
;
}
if (! bmpReadHeader(bmpFile)) {
if (!bmpReadHeader(bmpFile)) {
Serial.println("bad bmp");
return;
}
@ -80,7 +83,6 @@ void loop() {
delay(1000);
}
}
/*********************************************/
@ -90,15 +92,15 @@ void loop() {
// more RAM but makes the drawing a little faster. 20 pixels' worth
// is probably a good place
#define BUFFPIXEL 60 // must be a divisor of 240
#define BUFFPIXEL_X3 180 // BUFFPIXELx3
#define BUFFPIXEL 60 // must be a divisor of 240
#define BUFFPIXEL_X3 180 // BUFFPIXELx3
void bmpdraw(File f, int x, int y) {
bmpFile.seek(__Gnbmp_image_offset);
uint32_t time = millis();
uint8_t sdbuffer[BUFFPIXEL_X3]; // 3 * pixels to buffer
uint8_t sdbuffer[BUFFPIXEL_X3]; // 3 * pixels to buffer
for (int i = 0; i < __Gnbmp_height; i++) {
@ -110,9 +112,9 @@ void bmpdraw(File f, int x, int y) {
unsigned int __color[BUFFPIXEL];
for (int k = 0; k < BUFFPIXEL; k++) {
__color[k] = sdbuffer[buffidx + 2] >> 3; // read
__color[k] = __color[k] << 6 | (sdbuffer[buffidx + 1] >> 2); // green
__color[k] = __color[k] << 5 | (sdbuffer[buffidx + 0] >> 3); // blue
__color[k] = sdbuffer[buffidx + 2] >> 3; // read
__color[k] = __color[k] << 6 | (sdbuffer[buffidx + 1] >> 2); // green
__color[k] = __color[k] << 5 | (sdbuffer[buffidx + 0] >> 3); // blue
buffidx += 3;
}
@ -131,7 +133,6 @@ void bmpdraw(File f, int x, int y) {
TFT_CS_HIGH;
}
}
Serial.print(millis() - time, DEC);
@ -169,13 +170,11 @@ boolean bmpReadHeader(File f) {
int bmp_width = read32(f);
int bmp_height = read32(f);
if (bmp_width != __Gnbmp_width || bmp_height != __Gnbmp_height) { // if image is not 320x240, return false
if (bmp_width != __Gnbmp_width || bmp_height != __Gnbmp_height) { // if image is not 320x240, return false
return false;
}
if (read16(f) != 1) {
return false;
}
if (read16(f) != 1) { return false; }
bmpDepth = read16(f);
Serial.print("bitdepth ");

View File

@ -18,18 +18,19 @@
#include "TFTv2.h"
#define MAX_BMP 10 // bmp file num
#define FILENAME_LEN 20 // max file name length
#define MAX_BMP 10 // bmp file num
#define FILENAME_LEN 20 // max file name length
const int PIN_SD_CS = 4; // pin of sd card
const int PIN_SD_CS = 4; // pin of sd card
const long __Gnbmp_height = 320; // bmp height
const long __Gnbmp_width = 240; // bmp width
const long __Gnbmp_height = 320; // bmp height
const long __Gnbmp_width = 240; // bmp width
long __Gnbmp_image_offset = 0;;
long __Gnbmp_image_offset = 0;
;
int __Gnfile_num = 0; // num of file
char __Gsbmp_files[MAX_BMP][FILENAME_LEN]; // file name
int __Gnfile_num = 0; // num of file
char __Gsbmp_files[MAX_BMP][FILENAME_LEN]; // file name
File bmpFile;
@ -37,44 +38,30 @@ File bmpFile;
bool checkBMP(char *_name, char r_name[]) {
int len = 0;
if (NULL == _name) {
return false;
}
if (NULL == _name) { return false; }
while (*_name) {
r_name[len++] = *(_name++);
if (len > FILENAME_LEN) {
return false;
}
if (len > FILENAME_LEN) { return false; }
}
r_name[len] = '\0';
if (len < 5) {
return false;
}
if (len < 5) { return false; }
// if xxx.bmp or xxx.BMP
if (r_name[len - 4] == '.' \
&& (r_name[len - 3] == 'b' || (r_name[len - 3] == 'B')) \
&& (r_name[len - 2] == 'm' || (r_name[len - 2] == 'M')) \
&& (r_name[len - 1] == 'p' || (r_name[len - 1] == 'P'))) {
return true;
}
if (r_name[len - 4] == '.' && (r_name[len - 3] == 'b' || (r_name[len - 3] == 'B')) && (r_name[len - 2] == 'm' || (r_name[len - 2] == 'M')) && (r_name[len - 1] == 'p' || (r_name[len - 1] == 'P'))) { return true; }
return false;
}
// search root to find bmp file
void searchDirectory() {
File root = SD.open("/"); // root
File root = SD.open("/"); // root
while (true) {
File entry = root.openNextFile();
File entry = root.openNextFile();
if (! entry) {
break;
}
if (!entry) { break; }
if (!entry.isDirectory()) {
char *ptmp = entry.name();
@ -94,9 +81,7 @@ void searchDirectory() {
Serial.print(__Gnfile_num);
Serial.println(" file: ");
for (int i = 0; i < __Gnfile_num; i++) {
Serial.println(__Gsbmp_files[i]);
}
for (int i = 0; i < __Gnfile_num; i++) { Serial.println(__Gsbmp_files[i]); }
}
@ -114,7 +99,8 @@ void setup() {
if (!SD.begin(PIN_SD_CS)) {
Serial.println("failed!");
while (1); // init fail, die here
while (1)
; // init fail, die here
}
Serial.println("SD OK!");
@ -153,12 +139,13 @@ void loop() {
bmpFile = SD.open("pfvm_1.bmp");
if (! bmpFile) {
if (!bmpFile) {
Serial.println("didn't find image");
while (1);
while (1)
;
}
if (! bmpReadHeader(bmpFile)) {
if (!bmpReadHeader(bmpFile)) {
Serial.println("bad bmp");
return;
}
@ -166,7 +153,8 @@ void loop() {
bmpdraw(bmpFile, 0, 0, 1);
bmpFile.close();
while (1);
while (1)
;
}
/*********************************************/
@ -176,12 +164,12 @@ void loop() {
// more RAM but makes the drawing a little faster. 20 pixels' worth
// is probably a good place
#define BUFFPIXEL 60 // must be a divisor of 240
#define BUFFPIXEL_X3 180 // BUFFPIXELx3
#define BUFFPIXEL 60 // must be a divisor of 240
#define BUFFPIXEL_X3 180 // BUFFPIXELx3
#define UP_DOWN 1
#define DOWN_UP 0
#define UP_DOWN 1
#define DOWN_UP 0
// dir - 1: up to down
// dir - 2: down to up
@ -194,12 +182,10 @@ void bmpdraw(File f, int x, int y, int dir) {
uint32_t time = millis();
uint8_t sdbuffer[BUFFPIXEL_X3]; // 3 * pixels to buffer
uint8_t sdbuffer[BUFFPIXEL_X3]; // 3 * pixels to buffer
for (int i = 0; i < __Gnbmp_height; i++) {
if (dir) {
bmpFile.seek(__Gnbmp_image_offset + (__Gnbmp_height - 1 - i) * 240 * 3);
}
if (dir) { bmpFile.seek(__Gnbmp_image_offset + (__Gnbmp_height - 1 - i) * 240 * 3); }
for (int j = 0; j < (240 / BUFFPIXEL); j++) {
@ -210,9 +196,9 @@ void bmpdraw(File f, int x, int y, int dir) {
unsigned int __color[BUFFPIXEL];
for (int k = 0; k < BUFFPIXEL; k++) {
__color[k] = sdbuffer[buffidx + 2] >> 3; // read
__color[k] = __color[k] << 6 | (sdbuffer[buffidx + 1] >> 2); // green
__color[k] = __color[k] << 5 | (sdbuffer[buffidx + 0] >> 3); // blue
__color[k] = sdbuffer[buffidx + 2] >> 3; // read
__color[k] = __color[k] << 6 | (sdbuffer[buffidx + 1] >> 2); // green
__color[k] = __color[k] << 5 | (sdbuffer[buffidx + 0] >> 3); // blue
buffidx += 3;
}
@ -239,7 +225,6 @@ void bmpdraw(File f, int x, int y, int dir) {
TFT_CS_HIGH;
}
}
Serial.print(millis() - time, DEC);
@ -276,13 +261,11 @@ boolean bmpReadHeader(File f) {
int bmp_width = read32(f);
int bmp_height = read32(f);
if (bmp_width != __Gnbmp_width || bmp_height != __Gnbmp_height) { // if image is not 320x240, return false
if (bmp_width != __Gnbmp_width || bmp_height != __Gnbmp_height) { // if image is not 320x240, return false
return false;
}
if (read16(f) != 1) {
return false;
}
if (read16(f) != 1) { return false; }
bmpDepth = read16(f);
Serial.print("bitdepth ");