Skip to content

Commit ea1c76c

Browse files
committed
New BlueDisplay library
1 parent e2a9a5f commit ea1c76c

File tree

6 files changed

+56
-46
lines changed

6 files changed

+56
-46
lines changed

.github/workflows/TestCompile.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ jobs:
1616
- name: Checkout
1717
uses: actions/checkout@master
1818

19-
- name: Checkout custom library
20-
uses: actions/checkout@v2
21-
with:
22-
repository: ArminJo/Arduino-BlueDisplay
23-
ref: master
24-
path: CustomLibrary_BlueDisplay # must contain string "Custom"
19+
# - name: Checkout custom library
20+
# uses: actions/checkout@v2
21+
# with:
22+
# repository: ArminJo/Arduino-BlueDisplay
23+
# ref: master
24+
# path: CustomLibrary_BlueDisplay # must contain string "Custom"
2525

2626
- name: Compile all examples
2727
uses: ArminJo/arduino-test-compile@master
2828
with:
2929
sketch-names: SimpleTouchScreenDSO.cpp
3030
build-properties: '{ "All": "-DUSE_SIMPLE_SERIAL" }'
31-
# required-libraries: BlueDisplay
31+
required-libraries: BlueDisplay

FrequencyGeneratorPage.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@
3232
* GNU General Public License for more details.
3333
*
3434
* You should have received a copy of the GNU General Public License
35-
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
35+
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
3636
*
3737
*/
3838

3939
#if defined(AVR)
4040
#include "FrequencyGeneratorPage.h"
41+
#define SUPPRESS_HPP_WARNING
4142
#include "BlueDisplay.h"
42-
4343
#include "SimpleTouchScreenDSO.h"
4444

4545
#include <stdlib.h> // for dtostrf

SimpleTouchScreenDSO.cpp

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* GNU General Public License for more details.
1818
*
1919
* You should have received a copy of the GNU General Public License
20-
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
20+
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
2121
*
2222
* Features:
2323
* No dedicated hardware, just a plain arduino, a HC-05 Bluetooth module and this software.
@@ -159,10 +159,17 @@
159159
//#define DEBUG
160160
#include <Arduino.h>
161161

162+
/*
163+
* Settings to configure the BlueDisplay library and to reduce its size
164+
*/
165+
//#define BLUETOOTH_BAUD_RATE BAUD_115200 // Activate this, if you have reprogrammed the HC05 module for 115200, otherwise 9600 is used as baud rate
166+
//#define DO_NOT_NEED_BASIC_TOUCH_EVENTS // Disables basic touch events like down, move and up. Saves 620 bytes program memory and 36 bytes RAM
167+
#define USE_SIMPLE_SERIAL // Do not use the Serial object. Saves up to 1250 bytes program memory and 185 bytes RAM, if Serial is not used otherwise
168+
#include "BlueDisplay.hpp"
169+
162170
#include "SimpleTouchScreenDSO.h"
163171
#include "FrequencyGeneratorPage.h"
164172

165-
#include "BlueDisplay.h"
166173
#include "digitalWriteFast.h"
167174

168175
#if ! defined(USE_SIMPLE_SERIAL)
@@ -278,7 +285,7 @@ union Myword {
278285
uint8_t HighByte;
279286
} byte;
280287
uint16_t Word;
281-
uint8_t * BytePointer;
288+
uint8_t *BytePointer;
282289
};
283290

284291
// definitions from <wiring_private.h>
@@ -402,7 +409,7 @@ void setup() {
402409
DIDR0 = ADC0D | ADC1D | ADC2D | ADC3D | ADC4D | ADC5D;
403410

404411
// Must be simple serial for the DSO!
405-
initSimpleSerial(BLUETOOTH_BAUD_RATE);
412+
initSerial();
406413

407414
// initialize values
408415
MeasurementControl.isRunning = false;
@@ -523,7 +530,7 @@ void __attribute__((noreturn)) loop(void) {
523530

524531
for (;;) {
525532
checkAndHandleEvents();
526-
if (BlueDisplay1.mConnectionEstablished) {
533+
if (BlueDisplay1.mBlueDisplayConnectionEstablished) {
527534

528535
/*
529536
* Check for cyclic info output
@@ -724,7 +731,7 @@ void __attribute__((noreturn)) loop(void) {
724731
// loopFrequencyGeneratorPage();
725732
}
726733
}
727-
} // BlueDisplay1.mConnectionEstablished
734+
} // BlueDisplay1.mBlueDisplayConnectionEstablished
728735

729736
} // for(;;)
730737
}
@@ -1619,7 +1626,7 @@ uint16_t getAttenuatorFactor(void) {
16191626
/*
16201627
* toggle between DC and AC mode
16211628
*/
1622-
void doAcDcMode(__attribute__((unused)) BDButton * aTheTouchedButton, __attribute__((unused)) int16_t aValue) {
1629+
void doAcDcMode(__attribute__((unused)) BDButton *aTheTouchedButton, __attribute__((unused)) int16_t aValue) {
16231630
setACMode(!MeasurementControl.ChannelIsACMode);
16241631
}
16251632

@@ -1653,7 +1660,7 @@ void doSetTriggerDelay(float aValue) {
16531660
/*
16541661
* toggle between 5 and 1.1 volt reference
16551662
*/
1656-
void doADCReference(__attribute__((unused)) BDButton * aTheTouchedButton, __attribute__((unused)) int16_t aValue) {
1663+
void doADCReference(__attribute__((unused)) BDButton *aTheTouchedButton, __attribute__((unused)) int16_t aValue) {
16571664
uint8_t tNewReference = MeasurementControl.ADCReference;
16581665
if (MeasurementControl.ADCReference == DEFAULT) {
16591666
tNewReference = INTERNAL;
@@ -1668,7 +1675,7 @@ void doADCReference(__attribute__((unused)) BDButton * aTheTouchedButton, __a
16681675
}
16691676
}
16701677

1671-
void doStartStopDSO(__attribute__((unused)) BDButton * aTheTouchedButton, __attribute__((unused)) int16_t aValue) {
1678+
void doStartStopDSO(__attribute__((unused)) BDButton *aTheTouchedButton, __attribute__((unused)) int16_t aValue) {
16721679
if (MeasurementControl.isRunning) {
16731680
/*
16741681
* Stop here
@@ -2116,12 +2123,12 @@ void printVCCAndTemperature(void) {
21162123
#define HEAP_STACK_UNTOUCHED_VALUE 0x5A
21172124
void initStackFreeMeasurement(void) {
21182125
extern unsigned int __heap_start;
2119-
extern void * __brkval;
2126+
extern void *__brkval;
21202127
uint8_t v;
21212128

2122-
uint8_t *tHeapPtr = (uint8_t *) __brkval;
2129+
uint8_t *tHeapPtr = (uint8_t*) __brkval;
21232130
if (tHeapPtr == 0) {
2124-
tHeapPtr = (uint8_t *) &__heap_start;
2131+
tHeapPtr = (uint8_t*) &__heap_start;
21252132
}
21262133

21272134
// Fill memory

TouchDSOGui.cpp

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,24 @@
1919
* GNU General Public License for more details.
2020
*
2121
* You should have received a copy of the GNU General Public License
22-
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
22+
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
2323
*
2424
*/
2525

26+
#define SUPPRESS_HPP_WARNING
27+
2628
#if defined(AVR)
2729
#include <Arduino.h>
30+
2831
#include "SimpleTouchScreenDSO.h"
2932
#include "digitalWriteFast.h"
3033
#else
3134
#include "Pages.h"
3235
#include "TouchDSO.h"
3336

3437
#include "Chart.h" // for adjustIntWithScaleFactor()
35-
#endif
36-
3738
#include "BlueDisplay.h"
39+
#endif // defined(AVR)
3840

3941
uint8_t sLastPickerValue;
4042

@@ -502,7 +504,7 @@ const char sTriggerModeButtonStringManualTimeout[] PROGMEM = "Trigger\nman timeo
502504
const char sTriggerModeButtonStringManual[] PROGMEM = "Trigger\nman";
503505
const char sTriggerModeButtonStringFreeRunning[] PROGMEM = "Trigger\nfree";
504506
const char sTriggerModeButtonStringExternal[] PROGMEM = "Trigger\next";
505-
const char * const sTriggerModeButtonCaptionStringArray[] PROGMEM = { sTriggerModeButtonStringAuto,
507+
const char *const sTriggerModeButtonCaptionStringArray[] PROGMEM = { sTriggerModeButtonStringAuto,
506508
sTriggerModeButtonStringManualTimeout, sTriggerModeButtonStringManual, sTriggerModeButtonStringFreeRunning,
507509
sTriggerModeButtonStringExternal };
508510

@@ -522,7 +524,7 @@ const char StringTemperature[] PROGMEM = "Temp";
522524
const char StringVRefint[] PROGMEM = "VRef";
523525
const char StringVBattDiv2[] PROGMEM = "\xBD" "VBatt";
524526
#if defined(AVR)
525-
const char * const ADCInputMUXChannelStrings[] = { StringChannel0, StringChannel1, StringChannel2, StringChannel3, StringChannel4,
527+
const char *const ADCInputMUXChannelStrings[] = { StringChannel0, StringChannel1, StringChannel2, StringChannel3, StringChannel4,
526528
StringTemperature, StringVRefint };
527529
#else
528530
#if defined(STM)32F30X
@@ -540,15 +542,15 @@ const uint8_t ADCInputMUXChannels[] = {ADC_CHANNEL_0, ADC_CHANNEL_1, ADC_CHANNEL
540542
const char ChannelDivBy1ButtonString[] PROGMEM = "\xF7" "1";
541543
const char ChannelDivBy10ButtonString[] PROGMEM = "\xF7" "10";
542544
const char ChannelDivBy100ButtonString[] PROGMEM = "\xF7" "100";
543-
const char * const ChannelDivByButtonStrings[] = { ChannelDivBy1ButtonString,
544-
ChannelDivBy10ButtonString, ChannelDivBy100ButtonString };
545+
const char *const ChannelDivByButtonStrings[] =
546+
{ ChannelDivBy1ButtonString, ChannelDivBy10ButtonString, ChannelDivBy100ButtonString };
545547
BDButton TouchButtonChannelMode;
546548

547549
BDButton TouchButtonAutoOffsetMode;
548550
const char AutoOffsetButtonString0[] PROGMEM = "Offset\n0V";
549551
const char AutoOffsetButtonStringAuto[] PROGMEM = "Offset\nauto";
550552
const char AutoOffsetButtonStringMan[] PROGMEM = "Offset\nman";
551-
const char * const sAutoOffsetButtonCaptionStringArray[] PROGMEM = { AutoOffsetButtonString0, AutoOffsetButtonStringAuto,
553+
const char *const sAutoOffsetButtonCaptionStringArray[] PROGMEM = { AutoOffsetButtonString0, AutoOffsetButtonStringAuto,
552554
AutoOffsetButtonStringMan };
553555

554556
BDButton TouchButtonAutoRangeOnOff;
@@ -685,7 +687,7 @@ void initDSOGUI(void) {
685687

686688
// Button for channel select
687689
TouchButtonChannelSelect.init(REMOTE_DISPLAY_WIDTH - BUTTON_WIDTH_6, tPosY, BUTTON_WIDTH_6, SETTINGS_PAGE_BUTTON_HEIGHT,
688-
BUTTON_AUTO_RED_GREEN_FALSE_COLOR, reinterpret_cast<const __FlashStringHelper *>(StringChannel3), TEXT_SIZE_11,
690+
BUTTON_AUTO_RED_GREEN_FALSE_COLOR, reinterpret_cast<const __FlashStringHelper*>(StringChannel3), TEXT_SIZE_11,
689691
FLAG_BUTTON_DO_BEEP_ON_TOUCH, 42, &doChannelSelect);
690692

691693
// 4. row
@@ -1257,7 +1259,8 @@ void setAutoRangeModeAndButtonCaption(bool aNewAutoRangeMode) {
12571259
}
12581260

12591261
void setAutoOffsetButtonCaption(void) {
1260-
TouchButtonAutoOffsetMode.setCaptionFromStringArrayPGM(sAutoOffsetButtonCaptionStringArray, MeasurementControl.OffsetMode, (DisplayControl.DisplayPage == DISPLAY_PAGE_SETTINGS));
1262+
TouchButtonAutoOffsetMode.setCaptionFromStringArrayPGM(sAutoOffsetButtonCaptionStringArray, MeasurementControl.OffsetMode,
1263+
(DisplayControl.DisplayPage == DISPLAY_PAGE_SETTINGS));
12611264
}
12621265

12631266
void setACModeButtonCaption(void) {
@@ -1314,7 +1317,7 @@ void startDSOSettingsPage(void) {
13141317
* Use touch up in order not to interfere with long touch
13151318
* Switch between upper info line short/long/off
13161319
*/
1317-
void doSwitchInfoModeOnTouchUp(struct TouchEvent * const aTouchPosition) {
1320+
void doSwitchInfoModeOnTouchUp(struct TouchEvent *const aTouchPosition) {
13181321
#if defined(LOCAL_DISPLAY_EXISTS)
13191322
// first check for buttons
13201323
if (!TouchButton::checkAllButtons(aTouchPosition->TouchPosition.PosX, aTouchPosition->TouchPosition.PosY)) {
@@ -1351,7 +1354,7 @@ void doSwitchInfoModeOnTouchUp(struct TouchEvent * const aTouchPosition) {
13511354
* If stopped toggle between Start and Chart page
13521355
* If running toggle between gui display and chart only
13531356
*/
1354-
void doLongTouchDownDSO(struct TouchEvent * const aTochPosition) {
1357+
void doLongTouchDownDSO(struct TouchEvent *const aTochPosition) {
13551358
static bool sIsGUIVisible = false;
13561359
if (DisplayControl.DisplayPage == DISPLAY_PAGE_CHART) {
13571360
if (MeasurementControl.isRunning) {
@@ -1378,7 +1381,7 @@ void doLongTouchDownDSO(struct TouchEvent * const aTochPosition) {
13781381
/**
13791382
* responsible for swipe detection and dispatching
13801383
*/
1381-
void doSwipeEndDSO(struct Swipe * const aSwipeInfo) {
1384+
void doSwipeEndDSO(struct Swipe *const aSwipeInfo) {
13821385
#if defined(AVR)
13831386
uint8_t tFeedbackType = FEEDBACK_TONE_ERROR;
13841387
#else
@@ -1458,27 +1461,27 @@ void doSwipeEndDSO(struct Swipe * const aSwipeInfo) {
14581461
/*
14591462
* default handler for back button
14601463
*/
1461-
void doDefaultBackButton(BDButton * aTheTouchedButton, int16_t aValue) {
1464+
void doDefaultBackButton(BDButton *aTheTouchedButton, int16_t aValue) {
14621465
sBackButtonPressed = true;
14631466
}
14641467

14651468
/*
14661469
* show gui of settings screen
14671470
*/
1468-
void doShowSettingsPage(BDButton * aTheTouchedButton, int16_t aValue) {
1471+
void doShowSettingsPage(BDButton *aTheTouchedButton, int16_t aValue) {
14691472
DisplayControl.DisplayPage = DISPLAY_PAGE_SETTINGS;
14701473
redrawDisplay();
14711474
}
14721475

1473-
void doShowFrequencyPage(BDButton * aTheTouchedButton, int16_t aValue) {
1476+
void doShowFrequencyPage(BDButton *aTheTouchedButton, int16_t aValue) {
14741477
DisplayControl.DisplayPage = DISPLAY_PAGE_FREQUENCY;
14751478
startFrequencyGeneratorPage();
14761479
}
14771480

14781481
/*
14791482
* toggle between ascending and descending trigger slope
14801483
*/
1481-
void doTriggerSlope(BDButton * aTheTouchedButton, int16_t aValue) {
1484+
void doTriggerSlope(BDButton *aTheTouchedButton, int16_t aValue) {
14821485
MeasurementControl.TriggerSlopeRising = (!MeasurementControl.TriggerSlopeRising);
14831486
setTriggerLevelAndHysteresis(MeasurementControl.RawTriggerLevel, MeasurementControl.RawHysteresis);
14841487
setSlopeButtonCaption();
@@ -1487,7 +1490,7 @@ void doTriggerSlope(BDButton * aTheTouchedButton, int16_t aValue) {
14871490
/*
14881491
* switch between automatic, manual, free and external trigger mode
14891492
*/
1490-
void doTriggerMode(BDButton * aTheTouchedButton, int16_t aValue) {
1493+
void doTriggerMode(BDButton *aTheTouchedButton, int16_t aValue) {
14911494
uint8_t tNewMode = MeasurementControl.TriggerMode + 1;
14921495
if (tNewMode > TRIGGER_MODE_EXTERN) {
14931496
tNewMode = TRIGGER_MODE_AUTOMATIC;
@@ -1505,15 +1508,15 @@ void doTriggerMode(BDButton * aTheTouchedButton, int16_t aValue) {
15051508
setTriggerModeButtonCaption();
15061509
}
15071510

1508-
void doRangeMode(BDButton * aTheTouchedButton, int16_t aValue) {
1511+
void doRangeMode(BDButton *aTheTouchedButton, int16_t aValue) {
15091512
setAutoRangeModeAndButtonCaption(!MeasurementControl.RangeAutomatic);
15101513
}
15111514

15121515
/*
15131516
* step from 0 volt to auto to manual offset
15141517
* No auto offset in AC Mode for AVR
15151518
*/
1516-
void doOffsetMode(BDButton * aTheTouchedButton, int16_t aValue) {
1519+
void doOffsetMode(BDButton *aTheTouchedButton, int16_t aValue) {
15171520
MeasurementControl.OffsetMode++;
15181521
if (MeasurementControl.OffsetMode > OFFSET_MODE_MANUAL) {
15191522
// switch back from Mode Manual to mode 0 volt and set range mode to automatic
@@ -1537,7 +1540,7 @@ void doOffsetMode(BDButton * aTheTouchedButton, int16_t aValue) {
15371540
/*
15381541
* Cycle through all external and internal adc channels if button value is > 20
15391542
*/
1540-
void doChannelSelect(BDButton * aTheTouchedButton, int16_t aValue) {
1543+
void doChannelSelect(BDButton *aTheTouchedButton, int16_t aValue) {
15411544
#if defined(LOCAL_DISPLAY_EXISTS)
15421545
if (MeasurementControl.ADS7846ChannelsAsDatasource) {
15431546
// ADS7846 channels
@@ -1591,7 +1594,7 @@ void doChannelSelect(BDButton * aTheTouchedButton, int16_t aValue) {
15911594
/*
15921595
* Toggle history mode
15931596
*/
1594-
void doChartHistory(BDButton * aTheTouchedButton, int16_t aValue) {
1597+
void doChartHistory(BDButton *aTheTouchedButton, int16_t aValue) {
15951598
DisplayControl.showHistory = aValue;
15961599
if (DisplayControl.DisplayPage == DISPLAY_PAGE_SETTINGS) {
15971600
aTheTouchedButton->drawButton();
@@ -1611,7 +1614,7 @@ void doChartHistory(BDButton * aTheTouchedButton, int16_t aValue) {
16111614
/*
16121615
* set to singleshot mode and draw an indicating "S" for AVR
16131616
*/
1614-
void doStartSingleshot(BDButton * aTheTouchedButton, int16_t aValue) {
1617+
void doStartSingleshot(BDButton *aTheTouchedButton, int16_t aValue) {
16151618
aTheTouchedButton->deactivate();
16161619
MeasurementControl.isSingleShotMode = true;
16171620

@@ -1720,7 +1723,7 @@ void doVoltagePicker(BDSlider *aTheTouchedSlider, uint16_t aValue) {
17201723
/*
17211724
* Request delay value as number
17221725
*/
1723-
void doPromptForTriggerDelay(BDButton * aTheTouchedButton, int16_t aValue) {
1726+
void doPromptForTriggerDelay(BDButton *aTheTouchedButton, int16_t aValue) {
17241727
BlueDisplay1.getNumberWithShortPrompt(&doSetTriggerDelay, F("Trigger delay [\xB5s]"));
17251728
}
17261729

Waveforms.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* GNU General Public License for more details.
3838
*
3939
* You should have received a copy of the GNU General Public License
40-
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
40+
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
4141
*
4242
*/
4343

pictures/SettingsBluePill.png

41.9 KB
Loading

0 commit comments

Comments
 (0)