Browse Source

modified: src/main.cpp

yoneda 1 year ago
parent
commit
86142b5d26
3 changed files with 17 additions and 14 deletions
  1. 11 6
      platformio.ini
  2. 1 5
      src/display.cpp
  3. 5 3
      src/main.cpp

+ 11 - 6
platformio.ini

@@ -13,13 +13,18 @@ platform = wizio-pico
 board = raspberry-pi-pico
 framework = baremetal
 
-upload_protocol = picoprobe
-debug_tool = picoprobe
-;monitor_port = SERIAL_PORT
-;monitor_speed = 115200
+;upload_protocol = picoprobe
+;debug_tool = picoprobe
+monitor_port = COM4
+monitor_speed = 115200
+
+;board_build.nano = disable
+
 
-board_build.nano = disable
 
 ;lib_deps = 
 
-;build_flags = 
+build_flags =
+    -D PICO_USB
+    -D PICO_STDIO_USB
+

+ 1 - 5
src/display.cpp

@@ -9,10 +9,6 @@
 
 #include "font8x8.h"
 
-
-
-
-
 uint8_t display_buffer[OLED_BUF_LEN];
 
 void display_putchar(char c, uint8_t col_x, uint8_t col_y, bool reverse)
@@ -65,7 +61,7 @@ void display(void)
                                     buflen : 0 }; 
     calc_render_area_buflen(&frame_area);
     // ディスプレイクリア
-    fill(display_buffer, 0x0);
+    fill(display_buffer, 0x00);
     while(1) {
         render(display_buffer, &frame_area);
         sleep_us(6*1000);

+ 5 - 3
src/main.cpp

@@ -17,8 +17,8 @@
 #define HEARTBEAT_SAMPLE_CLOCK  50  // 50Hz
 
 uint16_t adc_buffer[ADC_BUF_LEN];   // ADC用リングバッファ
-uint16_t read_pointer = 0;          // バッファ用ポインタ
-uint16_t write_pointer = 0;
+volatile uint16_t read_pointer = 0;          // バッファ用ポインタ
+volatile uint16_t write_pointer = 0;
 
 // ADC割り込み
 void adc_handler(void)
@@ -46,6 +46,8 @@ int main(void)
 {
     uint32_t adc_clk;
 
+    stdio_init_all();
+
     // Display初期化
     multicore_reset_core1();
     multicore_launch_core1(display);
@@ -87,7 +89,7 @@ int main(void)
             if( val > LOWEST_VALUE ) {      // ADCの値から約1Vを切り捨てる
                 val -= LOWEST_VALUE;
             }
-            else val = 0;
+            else val = 1;
             // ドット位置の計算
             pos_y = (val * OLED_HEIGHT) / (4096 - LOWEST_VALUE) ;
             offset = (pos_y / 8) * OLED_WIDTH;