Skip to content

Commit

Permalink
Housekeeping
Browse files Browse the repository at this point in the history
  • Loading branch information
ArminJo committed Sep 30, 2023
1 parent d8800c3 commit bdcbf9d
Show file tree
Hide file tree
Showing 10 changed files with 167 additions and 103 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/TestCompile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ name: TestCompile
on: push
jobs:
build:
name: Test compiling examples for UNO
name: Test compiling examples for Uno
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down
40 changes: 20 additions & 20 deletions FrequencyGeneratorPage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#ifndef _FREQUENCY_GENERATOR_PAGE_HPP
#define _FREQUENCY_GENERATOR_PAGE_HPP

#if defined(AVR)
#if defined(__AVR__)
#include "FrequencyGeneratorPage.h"
#endif

Expand All @@ -48,7 +48,7 @@ static void (*sLastRedrawCallback)(void);

#define COLOR_BACKGROUND_FREQ COLOR16_WHITE

#if defined(AVR)
#if defined(__AVR__)
#define TIMER_PRESCALER_64 0x03
#define TIMER_PRESCALER_MASK 0x07
#endif
Expand All @@ -67,7 +67,7 @@ static void (*sLastRedrawCallback)(void);
/*
* Direct frequency + range buttons
*/
#if defined(AVR)
#if defined(__AVR__)
const uint16_t FixedFrequencyButtonCaptions[NUMBER_OF_FIXED_FREQUENCY_BUTTONS] PROGMEM
= { 1, 2, 5, 10, 20, 50, 100, 200, 500, 1000 };

Expand Down Expand Up @@ -133,7 +133,7 @@ void doGetFrequency(BDButton *aTheTouchedButton, int16_t aValue);
bool setWaveformFrequencyAndPrintValues();

void printFrequencyAndPeriod();
#if defined(AVR)
#if defined(__AVR__)
void setWaveformButtonCaption(void);
void initTimer1ForCTC(void);
#endif
Expand All @@ -143,7 +143,7 @@ void initTimer1ForCTC(void);
***********************/

void initFrequencyGenerator(void) {
#if defined(AVR)
#if defined(__AVR__)
initTimer1ForCTC();
#else
Synth_Timer_initialize(4711);
Expand Down Expand Up @@ -183,7 +183,7 @@ void startFrequencyGeneratorPage(void) {
sLastRedrawCallback = getRedrawCallback();
registerRedrawCallback(&drawFrequencyGeneratorPage);

#if !defined(AVR)
#if !defined(__AVR__)
Synth_Timer_Start();
#endif
}
Expand All @@ -205,7 +205,7 @@ void stopFrequencyGeneratorPage(void) {
TouchButtonFrequencyStartStop.deinit();
TouchButtonGetFrequency.deinit();
TouchSliderFrequency.deinit();
# if defined(AVR)
# if defined(__AVR__)
TouchButtonWaveform.deinit();
# endif
#endif
Expand All @@ -230,7 +230,7 @@ void initFrequencyGeneratorPageGui() {
*/
uint16_t tXPos = 0;
uint16_t tFrequency;
#if defined(AVR)
#if defined(__AVR__)
// captions are in PGMSPACE
const uint16_t *tFrequencyCaptionPtr = &FixedFrequencyButtonCaptions[0];
for (uint8_t i = 0; i < NUMBER_OF_FIXED_FREQUENCY_BUTTONS; ++i) {
Expand All @@ -251,7 +251,7 @@ void initFrequencyGeneratorPageGui() {
#endif

tXPos += BUTTON_WIDTH_10 + BUTTON_DEFAULT_SPACING_QUARTER;
#if defined(AVR)
#if defined(__AVR__)
tFrequencyCaptionPtr++;
#endif
}
Expand Down Expand Up @@ -284,7 +284,7 @@ void initFrequencyGeneratorPageGui() {
TouchButtonGetFrequency.init(BUTTON_WIDTH_3_POS_2, DISPLAY_HEIGHT - BUTTON_HEIGHT_4, BUTTON_WIDTH_3,
BUTTON_HEIGHT_4, COLOR16_BLUE, F("Hz..."), TEXT_SIZE_22, FLAG_BUTTON_DO_BEEP_ON_TOUCH, 0, &doGetFrequency);

#if defined(AVR)
#if defined(__AVR__)
TouchButtonWaveform.init(BUTTON_WIDTH_3_POS_3, DISPLAY_HEIGHT - BUTTON_HEIGHT_4, BUTTON_WIDTH_3,
BUTTON_HEIGHT_4, COLOR16_BLUE, "", TEXT_SIZE_18, FLAG_BUTTON_DO_BEEP_ON_TOUCH, sFrequencyInfo.Waveform, &doWaveformMode);
setWaveformButtonCaption();
Expand All @@ -304,7 +304,7 @@ void drawFrequencyGeneratorPage(void) {

BlueDisplay1.drawText(TEXT_SIZE_11_WIDTH, FREQ_SLIDER_Y + 3 * FREQ_SLIDER_SIZE + TEXT_SIZE_11_HEIGHT, F("1"), TEXT_SIZE_11,
COLOR16_BLUE, COLOR_BACKGROUND_FREQ);
#if defined(AVR)
#if defined(__AVR__)
BlueDisplay1.drawText(DISPLAY_WIDTH - 5 * TEXT_SIZE_11_WIDTH,
FREQ_SLIDER_Y + 3 * FREQ_SLIDER_SIZE + TEXT_SIZE_11_HEIGHT, F("1000"), TEXT_SIZE_11, COLOR16_BLUE,
COLOR_BACKGROUND_FREQ);
Expand Down Expand Up @@ -340,7 +340,7 @@ void drawFrequencyGeneratorPage(void) {

TouchButtonFrequencyStartStop.drawButton();
TouchButtonGetFrequency.drawButton();
#if defined(AVR)
#if defined(__AVR__)
TouchButtonWaveform.drawButton();
#endif

Expand Down Expand Up @@ -426,14 +426,14 @@ void doSetFrequencyRange(BDButton *aTheTouchedButton, int16_t aInputRangeIndex)
}
}

#if defined(AVR)
#if defined(__AVR__)
void setWaveformButtonCaption(void) {
TouchButtonWaveform.setCaption(getWaveformModePGMString(), (DisplayControl.DisplayPage == DSO_PAGE_FREQUENCY));
}
#endif

void doWaveformMode(BDButton *aTheTouchedButton, int16_t aValue) {
#if defined(AVR)
#if defined(__AVR__)
cycleWaveformMode();
setWaveformButtonCaption();
#endif
Expand Down Expand Up @@ -477,13 +477,13 @@ void doFrequencyGeneratorStartStop(BDButton *aTheTouchedButton, int16_t aValue)
sFrequencyInfo.isOutputEnabled = aValue;
if (aValue) {
// Start timer
#if !defined(AVR)
#if !defined(__AVR__)
Synth_Timer_Start();
#endif
setWaveformFrequencyAndPrintValues();
} else {
// Stop timer
#if defined(AVR)
#if defined(__AVR__)
stopWaveform();
#else
Synth_Timer_Stop();
Expand All @@ -498,7 +498,7 @@ void printFrequencyAndPeriod() {

float tPeriodMicros;

#if defined(AVR)
#if defined(__AVR__)
dtostrf(sFrequencyInfo.FrequencyNormalizedTo_1_to_1000, 9, 3, &sStringBuffer[20]);
sprintf_P(sStringBuffer, PSTR("%s%cHz"), &sStringBuffer[20], FrequencyRangeChars[sFrequencyInfo.FrequencyRangeIndex]);

Expand All @@ -520,7 +520,7 @@ void printFrequencyAndPeriod() {
tUnitChar = 'm';
}

#if defined(AVR)
#if defined(__AVR__)
dtostrf(tPeriodMicros, 10, 3, &sStringBuffer[20]);
sprintf_P(sStringBuffer, PSTR("%s%cs"), &sStringBuffer[20], tUnitChar);
#else
Expand Down Expand Up @@ -554,7 +554,7 @@ bool setWaveformFrequencyAndPrintValues() {
return tErrorOrClippingHappend;
}

#if !defined(AVR)
#if !defined(__AVR__)
// content for AVR is in Waveforms.cpp

#define WAVEFORM_SQUARE 0
Expand Down Expand Up @@ -643,6 +643,6 @@ bool setWaveformFrequencyFromNormalizedValues() {
float getPeriodMicros() {
return sFrequencyInfo.ControlValue.DividerInt / 36.0f;
}
#endif // !defined(AVR)
#endif // !defined(__AVR__)

#endif // _FREQUENCY_GENERATOR_PAGE_HPP
57 changes: 55 additions & 2 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007

Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.

Expand Down Expand Up @@ -618,4 +618,57 @@ an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.

END OF TERMS AND CONDITIONS
END OF TERMS AND CONDITIONS

How to Apply These Terms to Your New Programs

If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.

Also add information on how to contact you by electronic and paper mail.

If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:

<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".

You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.

The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This DSO needs only a standard Arduino-Uno or Arduino-Nano, a HC-05 Bluetooth mo
&nbsp; &nbsp;
[![Badge Commits since latest](https://img.shields.io/github/commits-since/ArminJo/Arduino-Simple-DSO/latest?color=yellow)](https://github.com/ArminJo/Arduino-Simple-DSO/commits/master)
&nbsp; &nbsp;
[![Badge Build Status](https://github.com/ArminJo/Arduino-Simple-DSO/workflows/LibraryBuild/badge.svg)](https://github.com/ArminJo/Arduino-Simple-DSO/actions)
[![Badge Build Status](https://github.com/ArminJo/Arduino-Simple-DSO/workflows/TestCompile/badge.svg)](https://github.com/ArminJo/Arduino-Simple-DSO/actions)
&nbsp; &nbsp;
![Badge Hit Counter](https://visitor-badge.laobi.icu/badge?page_id=ArminJo_Arduino-Simple-DSO)
<br/>
Expand Down Expand Up @@ -62,7 +62,7 @@ You can load the library with *Tools -> Manage Libraries...* or *Ctrl+Shift+I*.

Optional for Bluetooth connection
6. HC-05 Bluetooth module
7. Shottky diode e.g. BAT42
7. Schottky diode e.g. BAT42

# INSTRUCTIONS FOR USE
The DSO software has 4 pages.
Expand Down
18 changes: 9 additions & 9 deletions SimpleDSO.ino
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SimpleDSO.cpp
* SimpleDSO_BlueDisplay.cpp
*
* Copyright (C) 2015-2023 Armin Joachimsmeyer
* Email: [email protected]
Expand Down Expand Up @@ -172,10 +172,11 @@
#endif
#include "BlueDisplay.hpp"

#include "SimpleDSO.h"
#include "SimpleDSO_BlueDisplay.h"
#include "LocalDisplay/digitalWriteFast.h"
#include "FrequencyGeneratorPage.hpp" // include sources
#include "TouchDSOGui.hpp" // include sources
#include "ADCUtils.hpp" // for getVCCVoltage()

/**********************
* Buttons
Expand Down Expand Up @@ -258,7 +259,7 @@ extern volatile unsigned long timer0_millis;
*/
#define TRIGGER_WAIT_NUMBER_OF_SAMPLES 3300 // Number of samples (<=112us) used for detecting the trigger condition
#define ADC_CYCLES_PER_CONVERSION 13
#define SCALE_CHANGE_DELAY_MILLIS 2000
#define RANGE_CHANGE_DELAY_MILLIS 2000

#define ADC_MAX_CONVERSION_VALUE (1024 -1) // 10 bit
#define ATTENUATOR_FACTOR 10
Expand Down Expand Up @@ -348,7 +349,6 @@ void clearDisplayedChart(uint8_t *aDisplayBufferPtr);
void drawRemainingDataBufferValues(void);

//Hardware support section
float getTemperature(void);
void setVCCValue(void);
inline void setPrescaleFactor(uint8_t aFactor);
void setADCReferenceShifted(uint8_t aReferenceShifted);
Expand Down Expand Up @@ -521,7 +521,7 @@ void setup() {
/************************************************************************
* main loop - 32 microseconds
************************************************************************/
// noreturn saves 56 byte program memory!
// noreturn saves 56 byte program memory! but no stack
void __attribute__((noreturn)) loop(void) {
uint32_t sMillisOfLastInfoOutput;

Expand Down Expand Up @@ -583,7 +583,7 @@ void __attribute__((noreturn)) loop(void) {
} else if (DisplayControl.DisplayPage == DSO_PAGE_FREQUENCY) {
// refresh buttons
drawFrequencyGeneratorPage();
#if !defined(AVR)
#if !defined(__AVR__)
} else if (DisplayControl.DisplayPage == DSO_PAGE_MORE_SETTINGS) {
// refresh buttons
drawDSOMoreSettingsPage();
Expand Down Expand Up @@ -1536,7 +1536,7 @@ void computeAutoRange(void) {
* wait n-milliseconds before switch to higher resolution (lower index)
*/
uint32_t tActualMillis = millis();
if (tActualMillis - MeasurementControl.TimestampLastRangeChange > SCALE_CHANGE_DELAY_MILLIS) {
if (tActualMillis - MeasurementControl.TimestampLastRangeChange > RANGE_CHANGE_DELAY_MILLIS) {
MeasurementControl.TimestampLastRangeChange = tActualMillis;
setInputRange(tNewValueShift, tNewAttenuatorValue);
}
Expand Down Expand Up @@ -2026,7 +2026,7 @@ void printInfo(bool aRecomputeValues) {
getFloatFromRawValue(MeasurementControl.RawValueAverage), tPrecision, getFloatFromRawValue(tValueDiff),
tBufferForPeriodAndFrequency, tUnitsPerGrid, tTimebaseUnitChar);
#else
#if defined(AVR)
#if defined(__AVR__)

sprintf_P(sStringBuffer, PSTR("%sV %sV %5luHz %3u%cs"), tAverageStringBuffer, tP2PStringBuffer, tHertz,
tTimebaseUnitsPerGrid, tTimebaseUnitChar);
Expand Down Expand Up @@ -2101,7 +2101,7 @@ void printTriggerInfo(void) {
*/
void printVCCAndTemperature(void) {
if (!MeasurementControl.isRunning) {
float tTemp = getTemperature();
float tTemp = getCPUTemperature();
dtostrf(tTemp, 4, 1, &sStringBuffer[40]);

setVCCValue();
Expand Down
10 changes: 5 additions & 5 deletions SimpleDSO.h → SimpleDSO_BlueDisplay.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SimpleDSO.h
* SimpleDSO_BlueDisplay.h
*
* Copyright (C) 2015-2023 Armin Joachimsmeyer
* Email: [email protected]
Expand All @@ -20,8 +20,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
*/

#ifndef _SIMPLE_TOUCHSCREEN_DSO_H
#define _SIMPLE_TOUCHSCREEN_DSO_H
#ifndef _SIMPLE_DSO_BLUEDISPLAY_H
#define _SIMPLE_DSO_BLUEDISPLAY_H

#include "TouchDSOCommon.h"

Expand Down Expand Up @@ -245,7 +245,7 @@ void clearSingleshotMarker();
extern "C" void INT0_vect();

// for printf etc.
#if defined(AVR)
#if defined(__AVR__)
#define SIZEOF_STRINGBUFFER 50
#else
#define SIZEOF_STRINGBUFFER 240
Expand All @@ -256,4 +256,4 @@ extern BDButton TouchButtonBack;
// global flag for page control. Is evaluated by calling loop or page and set by buttonBack handler
extern bool sBackButtonPressed;

#endif // _SIMPLE_TOUCHSCREEN_DSO_H
#endif // _SIMPLE_DSO_BLUEDISPLAY_H
Loading

0 comments on commit bdcbf9d

Please sign in to comment.