Skip to content

Commit

Permalink
added option for switch buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
ardyesp committed Feb 26, 2017
1 parent 3645da8 commit d431553
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 20 deletions.
5 changes: 4 additions & 1 deletion DLO-138.ino
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
#include "variables.h"


#define FIRMWARE_VERSION "1.0"

// ------------------------
void setup() {
// ------------------------
DBG_INIT(SERIAL_BAUD_RATE);
DBG_PRINTLN("Dual channel O Scope");
DBG_PRINT("Dual channel O Scope with two logic channels, ver: ");
DBG_PRINTLN(FIRMWARE_VERSION);

// set digital and analog stuff
initIO();
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# DLO-138
An open source firmware for DSO-138 Oscilloscope.
![Photo](https://github.com/ardyesp/DLO-138/blob/master/pics/pic1.png)
![Photo](https://github.com/ardyesp/DLO-138/blob/master/pics/pic4.png)

DSO-138 is an excellent piece of hardware based on ARM Cortex M3 core STM32F103 processor and sufficient for most beginner users. The stock firmware, while quite responsive, can use a few improvements. The main shortcoming which prompted the development of DLO-138 firmware is the inability to get waveform data into a computer for further analysis and the lack of a second channel. Engineers troubleshooting hardware issues need to mark reference points on waveform so having another analog or digital channel can greatly improve analysis. This firmware hopes to improve on these issues.

Expand Down
Binary file added binaries/DLO-138_encoder_1.0.bin
Binary file not shown.
Binary file added binaries/DLO-138_switches_1.0.bin
Binary file not shown.
8 changes: 6 additions & 2 deletions display.ino
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ void drawLabels() {
}


#define DRAW_TIMEBASE
// #define DRAW_TIMEBASE

// ------------------------
void drawStats() {
Expand Down Expand Up @@ -756,8 +756,12 @@ void banner() {
tft.setCursor(30, 120);
tft.print("DSO-138 hardware by JYE-Tech");

tft.setCursor(30, 145);
tft.print("Firmware version: ");
tft.print(FIRMWARE_VERSION);

tft.setTextSize(1);
tft.setCursor(30, 170);
tft.setCursor(30, 200);
tft.print("GNU GENERAL PUBLIC LICENSE Version 3");
}

Expand Down
30 changes: 30 additions & 0 deletions encoder.ino
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,33 @@ void readEncoderISR() {
}
}



long lastABPress = 0;


// ------------------------
// ISR
void readASwitchISR() {
// ------------------------
if(millis() - lastABPress < BTN_DEBOUNCE_TIME)
return;
lastABPress = millis();

encoderChanged(-1);
}



// ------------------------
// ISR
void readBSwitchISR() {
// ------------------------
if(millis() - lastABPress < BTN_DEBOUNCE_TIME)
return;
lastABPress = millis();

encoderChanged(1);
}


21 changes: 9 additions & 12 deletions global.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
#define APP_DBG

// Setup debug printing macros.
#ifdef APP_DBG
#define DBG_INIT(...) { Serial.begin(__VA_ARGS__); }
#define DBG_PRINT(...) { Serial.print(__VA_ARGS__); }
#define DBG_PRINTLN(...) { Serial.println(__VA_ARGS__); }
#else
#define DBG_INIT(...) {}
#define DBG_PRINT(...) {}
#define DBG_PRINTLN(...) {}
#endif
// comment out following line to use DSO push buttons instead of encoder
#define USE_ENCODER

// serial print macros
#define DBG_INIT(...) { Serial.begin(__VA_ARGS__); }
#define DBG_PRINT(...) { Serial.print(__VA_ARGS__); }
#define DBG_PRINTLN(...) { Serial.println(__VA_ARGS__); }

#define SERIAL_BAUD_RATE 115200

Expand Down Expand Up @@ -73,3 +67,6 @@
// number of pixels waveform moves left/right or up/down
#define XCURSOR_STEP 25
#define YCURSOR_STEP 5


#define BTN_DEBOUNCE_TIME 350
5 changes: 2 additions & 3 deletions interface.ino
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#define DEBOUNCE_TIME 350


// ------------------------
Expand All @@ -24,7 +23,7 @@ void btn4ISR() {
// btn pressed or released?
if(!pressed && (digitalRead(BTN4) == LOW)) {
// debounce
if(millis() - pressedTime < DEBOUNCE_TIME)
if(millis() - pressedTime < BTN_DEBOUNCE_TIME)
return;
pressedTime = millis();
pressed = true;
Expand Down Expand Up @@ -57,7 +56,7 @@ void btn4ISR() {
void readESwitchISR() {
// ------------------------
// debounce
if(millis() - lastBtnPress < DEBOUNCE_TIME)
if(millis() - lastBtnPress < BTN_DEBOUNCE_TIME)
return;
lastBtnPress = millis();

Expand Down
8 changes: 7 additions & 1 deletion io.ino
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,15 @@ void initIO() {
pinMode(BTN4, INPUT_PULLUP);

attachInterrupt(ENCODER_SW, readESwitchISR, FALLING);
attachInterrupt(BTN4, btn4ISR, CHANGE);

#ifdef USE_ENCODER
attachInterrupt(ENCODER_A, readEncoderISR, CHANGE);
attachInterrupt(ENCODER_B, readEncoderISR, CHANGE);
attachInterrupt(BTN4, btn4ISR, CHANGE);
#else
attachInterrupt(ENCODER_A, readASwitchISR, FALLING);
attachInterrupt(ENCODER_B, readBSwitchISR, FALLING);
#endif

// init trigger level PWM
// start 20KHz square wave on trigger out reference and negative v gen
Expand Down
Binary file added pics/pic4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d431553

Please sign in to comment.