summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVasil Zlatanov <v@skozl.com>2017-05-11 09:19:33 +0100
committerVasil Zlatanov <v@skozl.com>2017-05-11 09:19:33 +0100
commitaa402760fb91529f6e75e15959a18bd2070562a2 (patch)
treeeaddd2e20c8bad40e4f5cda2a467e29f8cf2c467 /src
parent712cad848d3d70295a854f9fcf4b93376db1f738 (diff)
downloade2-switch-aa402760fb91529f6e75e15959a18bd2070562a2.tar.gz
e2-switch-aa402760fb91529f6e75e15959a18bd2070562a2.tar.bz2
e2-switch-aa402760fb91529f6e75e15959a18bd2070562a2.zip
Fix formatting in selectable wave type
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 15e7e60..5e0c471 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -37,7 +37,7 @@ uint16_t sample = 0;
uint16_t sineArray[SINA_SIZE];
-int wave_type = 0;
+int wave_type = -1;
// Initialise display
SPInit gSpi(D_MOSI_PIN, NC, D_CLK_PIN);
@@ -67,21 +67,22 @@ int main(void)
timer.attach_us(&tout, SW_PERIOD);
oled.clearDisplay();
- oled.printf("%ux%u Group Ay08-04\r\n", oled.width(), oled.height());
for (;;) {
if (update) {
update = 0;
oled.setTextCursor(0, 0);
+ oled.printf("Wave type: %d \n", wave_type);
+ oled.printf("Sq:2 Tr:1 Sin:0");
// Write the latest switch osciallor count
for (int i = 3; i >= 0; --i) {
if (wave_type < 0){
- oled.printf("Select type of wave\n");
- oled.printf("Square:2 Triangle:1 Sine:0");
- if (switch_pressed[i] && !last_pressed[i])
+ if (switch_pressed[i] && !last_pressed[i]){
wave_type = i;
+ oled.setTextCursor(0, 0);
+ }
} else {
current_f[i] += (switch_pressed[i] && !last_pressed[i]);
if (current_f[i] > 9)
@@ -100,10 +101,10 @@ int main(void)
if (frequency){
switch(wave_type){
case 1:
- pwm.attach_us( &square, 1000000 / (frequency * SINA_SIZE));
+ pwm.attach_us( &triangle, 1000000 / (frequency * SINA_SIZE));
break;
case 0:
- pwm.attach_us( &triangle, 1000000 / (frequency * 100));
+ pwm.attach_us( &sine, 1000000 / (frequency * 100));
break;
default:
pwm.attach_us( &square, 1000000 / (frequency * 2));