Skip to content

Commit 4abd671

Browse files
committed
Init ver
0 parents  commit 4abd671

9 files changed

+88
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.o

BunHMI/bun_arduino.bun

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"model":"MS-40RJ0","configs":{"proj_name":"my_proj","baudrate":115200,"startup_script":""},"gui_vertical":false,"version":"0.0.1","ImportFonts":[],"EmbedFonts":[{"name":"lv_font_montserrat_12","var_name":"","font":"Montserrat medium","size":12,"bpp":8,"latters":0,"symbols":"","buildin":true},{"name":"lv_font_montserrat_14","var_name":"","font":"Montserrat medium","size":14,"bpp":8,"latters":0,"symbols":"","buildin":true},{"name":"lv_font_montserrat_16","var_name":"","font":"Montserrat medium","size":16,"bpp":8,"latters":0,"symbols":"","buildin":true},{"name":"lv_font_montserrat_20","var_name":"","font":"Montserrat medium","size":20,"bpp":8,"latters":0,"symbols":"","buildin":true},{"name":"lv_font_montserrat_24","var_name":"","font":"Montserrat medium","size":24,"bpp":8,"latters":0,"symbols":"","buildin":true}],"ImportImages":[{"id":1,"file":"blue_480x320.jpg","type":"jpg"},{"id":2,"file":"t_scale_bg.png","type":"png"},{"id":3,"file":"t_scale_ind.png","type":"png"}],"screens":[{"w_name":"Screen1","w_id":"screen","x":0,"y":0,"width":480,"height":320,"width_unit":"px","height_unit":"px","size_type":1,"dragable":false,"has_text_style":true,"w_type":1,"layoutAlign":0,"options":[],"w_children":[{"x":-5,"y":-124,"width":68,"height":24,"width_unit":"fit","height_unit":"fit","size_type":2,"dragable":true,"layoutAlign":0,"w_id":"widget_1","w_name":"lab","w_children":[],"options":[{"name":"text","value":"Label"},{"name":"text_recolor","value":"0"}],"lv_events":[{"event":"EVENT_CLICKED","script":""}],"lv_styles":[{"part":"PART_MAIN","state":"STATE_DEFAULT","property":"text_color","value":"rgba(255,0,0,1)","enable":true},{"part":"PART_MAIN","state":"STATE_DEFAULT","property":"text_font","value":"lv_font_montserrat_24","enable":true}],"w_type":8,"lv_states":[],"lv_flags":[{"name":"FLAG_HIDDEN","val":false},{"name":"FLAG_CLICKABLE","val":true},{"name":"FLAG_CHECKABLE","val":false}],"no_children":true,"has_text_style":true},{"x":0,"y":-76,"width":300,"height":30,"width_unit":"px","height_unit":"px","size_type":0,"dragable":true,"layoutAlign":0,"w_id":"widget_2","w_name":"sli","w_children":[],"options":[{"name":"slider_min","value":"0"},{"name":"slider_max","value":"100"},{"name":"slider_mode","value":"NORMAL"},{"name":"slider_value","value":"30"},{"name":"slider_value_left","value":"0"}],"lv_events":[{"event":"EVENT_CLICKED","script":""},{"event":"EVENT_VALUE_CHANGED","script":"ptr(\"SLI:\", sli.val());\nservo.text(strcat(\"Servo:\",sli.val()))"}],"lv_styles":[],"w_type":16,"lv_states":[],"lv_flags":[{"name":"FLAG_HIDDEN","val":false},{"name":"FLAG_CLICK_FOCUSABLE","val":true}],"has_radius":true,"no_children":true,"has_text_style":false},{"x":-159,"y":111,"width":99,"height":50,"width_unit":"px","height_unit":"px","size_type":0,"dragable":true,"layoutAlign":0,"w_id":"widget_3","w_name":"sw","w_children":[],"options":[],"lv_events":[{"event":"EVENT_CLICKED","script":""},{"event":"EVENT_VALUE_CHANGED","script":"ptr(\"LED:\", sw.checked());\nled.text(strcat(\"LED=\", sw.checked()));\nsys.beep(2000, 100)"}],"lv_styles":[],"w_type":15,"lv_states":[],"lv_flags":[{"name":"FLAG_HIDDEN","val":false},{"name":"FLAG_CLICKABLE","val":true},{"name":"FLAG_PRESS_LOCK","val":true},{"name":"FLAG_ADV_HITTEST","val":true}],"no_children":true,"has_text_style":false},{"x":-58,"y":110,"width":52,"height":24,"width_unit":"fit","height_unit":"fit","size_type":2,"dragable":true,"layoutAlign":0,"w_id":"widget_4","w_name":"led","w_children":[],"options":[{"name":"text","value":"LED"},{"name":"text_recolor","value":"0"}],"lv_events":[{"event":"EVENT_CLICKED","script":""}],"lv_styles":[{"part":"PART_MAIN","state":"STATE_DEFAULT","property":"text_color","value":"rgba(255,0,0,1)","enable":true},{"part":"PART_MAIN","state":"STATE_DEFAULT","property":"text_font","value":"lv_font_montserrat_24","enable":true}],"w_type":8,"lv_states":[],"lv_flags":[{"name":"FLAG_HIDDEN","val":false},{"name":"FLAG_CLICKABLE","val":true},{"name":"FLAG_CHECKABLE","val":false}],"no_children":true,"has_text_style":true},{"x":179,"y":5,"width":70,"height":295,"width_unit":"px","height_unit":"px","size_type":0,"dragable":true,"layoutAlign":0,"w_id":"widget_7","w_name":"bar","w_children":[],"options":[{"name":"bar_min","value":"0"},{"name":"bar_max","value":"100"},{"name":"bar_mode","value":"NORMAL"},{"name":"bar_value","value":"30"},{"name":"bar_value_start","value":"0"}],"lv_events":[{"event":"EVENT_CLICKED","script":""}],"lv_styles":[{"part":"PART_MAIN","state":"STATE_DEFAULT","property":"bg_image","value":"t_scale_bg.png","enable":true},{"part":"PART_MAIN","state":"STATE_DEFAULT","property":"bg_color","value":"rgba(227,8,8,0)","enable":true},{"part":"PART_INDICATOR","state":"STATE_DEFAULT","property":"bg_image","value":"t_scale_ind.png","enable":true},{"part":"PART_INDICATOR","state":"STATE_DEFAULT","property":"bg_color","value":"rgba(0,0,0,0)","enable":true}],"w_type":5,"lv_states":[],"lv_flags":[{"name":"FLAG_HIDDEN","val":false}],"has_radius":true,"no_children":true,"has_text_style":false},{"x":0,"y":0,"width":70,"height":24,"width_unit":"fit","height_unit":"fit","size_type":2,"dragable":true,"layoutAlign":0,"w_id":"widget_8","w_name":"servo","w_children":[],"options":[{"name":"text","value":"Servo"},{"name":"text_recolor","value":"0"}],"lv_events":[{"event":"EVENT_CLICKED","script":""}],"lv_styles":[{"part":"PART_MAIN","state":"STATE_DEFAULT","property":"text_color","value":"rgba(255,0,0,1)","enable":true},{"part":"PART_MAIN","state":"STATE_DEFAULT","property":"text_font","value":"lv_font_montserrat_24","enable":true}],"w_type":8,"lv_states":[],"lv_flags":[{"name":"FLAG_HIDDEN","val":false},{"name":"FLAG_CLICKABLE","val":true},{"name":"FLAG_CHECKABLE","val":false}],"no_children":true,"has_text_style":true}],"lv_events":[{"event":"EVENT_SCREEN_LOADED","script":""},{"event":"EVENT_SCREEN_UNLOADED","script":""}],"lv_styles":[{"part":"PART_MAIN","state":"STATE_DEFAULT","property":"bg_image","value":"blue_480x320.jpg","enable":true}],"lv_states":[],"lv_flags":[{"name":"FLAG_SCROLLABLE","val":true}],"lv_scrollmode":"MODE_AUTO","lv_scrolldir":"DIR_ALL"}]}

BunHMI/images/blue_480x320.jpg

14.5 KB
Loading

BunHMI/images/t_scale_bg.png

3.9 KB
Loading

BunHMI/images/t_scale_ind.png

2.45 KB
Loading

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# BunHMI arduino demo
2+
This project demo how to use arduino interact with BunHMI.
3+
4+
5+
![RPI-pico link with BunHMI](./images/BunHMI_link.png)

Readme.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# BunHMI arduino demo
2+
This project demo how to use arduino interact with BunHMI.
3+
4+
5+
![RPI-pico link with BunHMI](./images/BunHMI_link.png)

arduino_pico/arduino_pico.ino

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
AnalogReadSerial
3+
4+
Reads an analog input on pin 0, prints the result to the Serial Monitor.
5+
Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu).
6+
Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
7+
8+
This example code is in the public domain.
9+
10+
https://www.arduino.cc/en/Tutorial/BuiltInExamples/AnalogReadSerial
11+
*/
12+
13+
#include <arduino-timer.h>
14+
15+
auto timer = timer_create_default();
16+
int sec_tick_cnt = 0;
17+
18+
int test_cnt = 0;
19+
20+
bool sys_tick(void*){
21+
char buff[128];
22+
if(++sec_tick_cnt >= 1000){
23+
// 1 Sec
24+
sec_tick_cnt = 0;
25+
snprintf(buff, sizeof(buff),"w4.text(\"CNT:%d\")\n", test_cnt++);
26+
Serial1.print(buff);
27+
}
28+
if((sec_tick_cnt % 100) == 0){
29+
// 100ms
30+
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN)); // turn the LED on (HIGH is the voltage level)
31+
32+
int sensorValue = (analogRead(A0)*100)/1024;
33+
snprintf(buff, sizeof(buff),"w2.val(%d,1)\n", sensorValue);
34+
Serial1.print(buff);
35+
}
36+
return true;
37+
}
38+
39+
// the setup routine runs once when you press reset:
40+
void setup() {
41+
// initialize digital pin LED_BUILTIN as an output.
42+
pinMode(LED_BUILTIN, OUTPUT);
43+
// initialize serial communication at 9600 bits per second:
44+
Serial1.setRX(PIN_SERIAL1_RX);
45+
Serial1.setTX(PIN_SERIAL1_TX);
46+
Serial1.begin(115200);
47+
//Serial1.println("Hello Pico");
48+
49+
Serial.begin(9600); // USB serial
50+
51+
timer.every(1, sys_tick);
52+
}
53+
54+
55+
56+
// the loop routine runs over and over again forever:
57+
void loop() {
58+
timer.tick();
59+
60+
if(Serial1.available()){
61+
String str = Serial1.readString();
62+
Serial.print(str);
63+
}
64+
65+
// read the input on analog pin 0:
66+
67+
// int sensorValue = analogRead(A0);
68+
// // print out the value you read:
69+
// digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
70+
// Serial1.println(sensorValue);
71+
// delay(100); // delay in between reads for stability
72+
// Serial.print("USB Ser=");
73+
// Serial.println(sensorValue);
74+
// digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
75+
// delay(100); // wait for a second
76+
}

images/BunHMI_link.png

114 KB
Loading

0 commit comments

Comments
 (0)