https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
https://github.com/pt-robotics/esp32/raw/main/package_ptbot_index.json
https://raw.githubusercontent.com/pt-robotics/esp32/main/package_ptbot_index.json
https://drive.google.com/file/d/1jamHcOeHR16KQZjnvZ_rsELLJQ-m_63q/view?usp=sharing
https://drive.google.com/drive/folders/1ed9D4bTDKp_FsfHNXJn4tEBsFdINEuQp?usp=sharing
void STOP() {
motorStop();
setAngleOffset();
current_degree = 0;
vTaskResume(sonarTaskHandle);
sonar_enable = 1;
const int num_sensor = 4;
int sensor_raw[num_sensor];
int sensor_map[num_sensor];
float last_sonar = -1;
tft.fillScreen(0x0000);
tft.setTextSize(1);
while (!switchRead(A) && !switchRead(B)) {
/* ---------- READ DATA ---------- */
float yaw = angleRead(YAW);
float sonar_cm = readSonar();
if (sonar_cm > 1 && sonar_cm < 400)
last_sonar = sonar_cm;
for (int i = 0; i < num_sensor; i++) {
sensor_raw[i] = adcRead(i);
sensor_map[i] = map(sensor_raw[i],
sensor_min[i],
sensor_max[i],
0, 100);
if (sensor_map[i] < 0) sensor_map[i] = 0;
if (sensor_map[i] > 100) sensor_map[i] = 100;
}
/* ---------- CLEAR CONTENT AREA ---------- */
tft.fillRect(0, 0, 160, 128, 0x0000);
/* ================= HEADER ================= */
tft.setTextColor(0x07E0);
tft.setCursor(30, 5);
tft.print("READY / DEBUG");
/* ================= YAW / SONAR ================= */
tft.setTextColor(0xFFFF);
tft.setCursor(5, 22);
tft.print("YAW");
tft.fillRect(40, 20, 45, 14, 0xFFFF);
tft.setTextColor(0x0000);
tft.setCursor(45, 22);
tft.print(yaw, 1);
tft.setTextColor(0xFFFF);
tft.setCursor(95, 22);
tft.print("SON");
tft.fillRect(125, 20, 30, 14, 0xFFFF);
tft.setTextColor(0x0000);
tft.setCursor(128, 22);
if (last_sonar < 0)
tft.print("--");
else
tft.print((int)last_sonar);
/* ================= LINE SENSOR RAW ================= */
tft.setTextColor(0xF800); // แดง
tft.setCursor(5, 70);
tft.print("RAW:");
tft.setTextColor(0xFFFF);
for (int i = 0; i < 4; i++) {
tft.setCursor(5 + (i * 38), 85);
tft.print(sensor_raw[i]);
}
/* ================= LINE SENSOR MAP ================= */
tft.setTextColor(0x07FF); // ฟ้า
tft.setCursor(5, 100);
tft.print("MAP:");
tft.setTextColor(0xFFFF);
for (int i = 0; i < 4; i++) {
tft.setCursor(5 + (i * 38), 115);
tft.print(sensor_map[i]);
}
delay(80);
}
delay(300);
tft.fillScreen(0x0000);
}