Sensor Dashboard

Lab 8: Real Sensor Dashboard (Based on Ex5)

1. โครงสร้างภาพรวมของ Lab

Why? - ทำไมต้องเรียนรู้เรื่องนี้

  • Multi-Sensor: รวม ADC, Accelerometer, Gyroscope ใน dashboard เดียว

  • Real APIs: ใช้ aic_adc_read(), aic_imu_read_accel(), aic_imu_read_gyro()

  • TabView Organization: จัดการข้อมูลหลายประเภทด้วย tabs

What? - จะได้เรียนรู้อะไร

  1. Multiple Sensor APIs: อ่านค่าจากหลาย sensor

  2. TabView Integration: รวม widgets หลายประเภทใน tabs

  3. Single Timer: อัพเดทหลาย widgets จาก timer เดียว

  4. Data Mapping: แปลงค่า sensor เป็นค่าแสดงผล

How? - จะทำอย่างไร

  1. เพิ่ม aic_sensors_init() ก่อนสร้าง TabView

  2. Timer callback อ่านค่าจากทุก sensor APIs

  3. อัพเดท ADC Bar, Accel Chart, Gyro Arcs ใน callback เดียว


2. หลักการทำงานและ Flowchart

2.1 Dashboard Architecture

2.2 TabView Layout

2.3 Data Mapping


3. ฟังก์ชันสำคัญ

3.1 Sensor APIs Used

Function
Return
Description

aic_sensors_init()

void

Initialize all sensors

aic_adc_read(AIC_ADC_CH0)

uint16_t

Read ADC channel 0 (0-4095)

aic_imu_read_accel(&ax,&ay,&az)

bool

Read accelerometer (m/s²)

aic_imu_read_gyro(&gx,&gy,&gz)

bool

Read gyroscope (rad/s)

3.2 Widget Functions

Tab
Widget
Key Functions

ADC

lv_bar

lv_bar_set_value(), lv_bar_set_range()

Accel

lv_chart

lv_chart_set_next_value()

Gyro

lv_arc

lv_arc_set_value(), lv_arc_set_range()


4. Code Example

4.1 Timer Callback (All Sensors)

4.2 Create Gyro Tab (with Large Arcs)

4.3 Main Function


5. องค์ความรู้และเทคนิค

5.1 Gyroscope Data Mapping

5.2 Single Timer for Multiple Sensors

5.3 Tab Content Styling


6. แบบฝึกหัด

Exercise 1: ADC with Color Threshold

เปลี่ยนสี ADC Bar ตามค่า:

  • Green: 0-30%

  • Yellow: 31-70%

  • Red: 71-100%

Exercise 2: Active Tab Optimization

อัพเดทเฉพาะ tab ที่ active เท่านั้น เพื่อเพิ่ม performance


7. References


Previous Lab: Lab 7: Real IMU Display Next Lab: Lab 9: Real Arc Gauge

Last updated

Was this helpful?