#include "SPI.h" #include <EEPROM.h> #include <AdafruitGFXAS.h> //…
- User
#include "SPI.h" #include <EEPROM.h> #include <Adafruit_GFX_AS.h> // http://rcl-radio.ru/wp-content/uploads/2020/06/Adafruit_GFX.zip #include <Adafruit_ILI9341_STM.h> #include <STM32ADC.h> #include <HardwareTimer.h>
#define maxSamples 1000 #define SIGNAL_INPUT PA0 #define HOLD_BUTTON PB12 // HOLD #define MORE_BUTTON PB13 // + #define LESS_BUTTON PB14 // - #define SET_BUTTON PB15 // SET #define TFT_CS PB1 #define TFT_DC PB10 #define TFT_RST PB11 // MOSI PA7 // SCK PA5 // MISO (unnecessary)
STM32ADC myADC(ADC1); uint8 pin = SIGNAL_INPUT; volatile static bool dma1_ch1_Active; uint16_t buffer[maxSamples]; uint16 dataPoints[maxSamples]; Adafruit_ILI9341_STM tft = Adafruit_ILI9341_STM(TFT_CS, TFT_DC, TFT_RST);
byte data[1000], data_old[1000]; int setting, hold_set, i, x, y, i2, u_max, u_min, minn, u_sinh, mn = 2, raz, per, razv, sinhro; int u1, u2, t1, t2, zap, ux = 1, uxx = 1, fun; long h0, h1; long times, times1, hhh, times2, times3, tim; byte hold, www, w = 1, w1 = 1, w2 = 1, w3 = 1, w4 = 1, link, w5 = 1, b1 = 1, b2 = 1; String raz_x; float k1, k2, del = 1;
int data1[1000];
void setup() { Serial.begin(115200); EEPROM.init(0x801F000, 0x801F800, 0x400); // 1024 byte
pinMode(SIGNAL_INPUT, INPUT_ANALOG); pinMode(HOLD_BUTTON, INPUT_PULLUP); pinMode(MORE_BUTTON, INPUT_PULLUP); pinMode(LESS_BUTTON, INPUT_PULLUP); pinMode(SET_BUTTON, INPUT_PULLUP);
tft.begin(); tft.setRotation(1); tft.fillScreen(ILI9341_BLACK); razv = EEPROM.read(0); sinhro = EEPROM.read(1);
ADC1->regs->CR1 = 0; // Clear control register ADC1->regs->SQR1 = 0; // Clear register SQR1 ADC1->regs->CR2 |= ADC_CR2_CAL; // Start calibration while (!(ADC1->regs->CR2 & ADC_CR2_CAL)) {};
}
void loop() {
if (digitalRead(SET_BUTTON) == LOW && hold == 0) { w = 1; w1 = 1; b1 = 1; b2 = 0; setting++; if (setting > 2) { setting = 0; } delay(300); } if (digitalRead(SET_BUTTON) == LOW && hold == 1) { w = 1; w2 = 1; w4 = 1; hold_set++; if (hold_set > 4) { hold_set = 0; } delay(300); }
////// TFT ////////////////////////////////////////// tft.setCursor(295, 0); tft.setTextColor(ILI9341_WHITE); tft.setTextSize(1); //////////////////// HOLD ON OFF /////////////////////////////////////////// if (digitalRead(HOLD_BUTTON) == LOW && hold == 0) { hold = 1; w2 = 1; w4 = 1; link = 1; setting = 0; delay(300); } if (digitalRead(HOLD_BUTTON) == LOW && hold == 1) { hold = 0; www = 1; b2 = 0; hold_set = 0; delay(300); }
if (link == 1) { link = 0; tft.fillRect(170, 0, 100, 30, ILI9341_BLACK); } if (hold == 0) { tft.setCursor(170, 0); tft.print("OSCILLOSCOPE"); tft.setCursor(170, 10); tft.print("VERSION 0.1"); tft.setCursor(170, 20); tft.print("RCL-RADIO.RU"); }
- Assistant
Hello! It looks like you've shared the code for an oscilloscope project using an STM32 microcontroller and various Arduino libraries. I'd be happy to help you with any questions or issues you might have.
Here are some ways I can assist:
- Code Review: I can review your code and provide suggestions for improvements or optimizations.
- Debugging: If you're encountering errors or unexpected behavior, I can help you identify and resolve them.
- Feature Enhancement: If you're looking to add new features or functionalities, I can provide guidance on how to implement them.
- Explanation: I can explain how certain parts of your code work or why certain programming techniques are used.
Please let me know how I can assist you further!