From 612aa64768248bcd11f827e42c875c02dbb308c3 Mon Sep 17 00:00:00 2001 From: JR3XNW <121542251+JR3XNW@users.noreply.github.com> Date: Thu, 16 Mar 2023 08:49:54 +0900 Subject: [PATCH] Add files via upload --- pico_BandScope_v1_128x32.ino | 188 +++++++++++++++++++++++++++++++++++ 1 file changed, 188 insertions(+) create mode 100644 pico_BandScope_v1_128x32.ino diff --git a/pico_BandScope_v1_128x32.ino b/pico_BandScope_v1_128x32.ino new file mode 100644 index 0000000..d33eeb5 --- /dev/null +++ b/pico_BandScope_v1_128x32.ino @@ -0,0 +1,188 @@ +/* + OLED 128x32 Bandscope JR3XNW 2023/3/14 + Library to add + arduinoFFT.h + Wire.h + U8g2lib.h +*/ + +#include +#include +#include "arduinoFFT.h" + +//**************************FFT***************************** +#define I_IN 26 //I-Input pins +#define Q_IN 27 //Q-Input pins +#define MOD_BUTTON 2 //mode switching + +#define PX1 63 //Positive frequency screen (Q) origin 62 +#define PY1 23 //Bottom edge of spectrum screen 42 +#define PY2 24 //56 +#define SAMPLES 256 //Must be a power of 2 +#define WFrow 12 + +int mod = 0; + +//U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/U8X8_PIN_NONE); +U8G2_SSD1306_128X32_UNIVISION_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); + +arduinoFFT FFT = arduinoFFT(); + +double vReal[SAMPLES]; +double vImag[SAMPLES]; + +byte DSdata[256]; +byte WFdata[WFrow][128]; + +void setup() { + pinMode(25, OUTPUT); // pico built-in LED + pinMode(MOD_BUTTON,INPUT_PULLUP); //MODE_SWITCHING Set to input and pull-up + Serial.begin(115200); + + analogReadResolution(12); // Set ADC full scale to 12 bits + u8g2.begin(); + u8g2.setFont(u8g2_font_6x10_tf); + u8g2.setDrawColor(1); + u8g2.setFontPosTop(); // The upper left corner is used as the character position reference. + u8g2.clearBuffer(); + u8g2.drawStr(0, 0, "Band Scope v0.1"); + u8g2.sendBuffer(); + delay(500); + +} + +void loop() { + digitalWrite(25, HIGH); // Built-in LED lights up during sampling + if(digitalRead(MOD_BUTTON) == LOW){Mod_Stp();} //When MOD_BUTTON is pressed, change mode + + /*SAMPLING*/ + if ( mod == 0 ) { + for(int i=0; i