summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 5e0c471..64231fc 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -39,6 +39,8 @@ uint16_t sineArray[SINA_SIZE];
int wave_type = -1;
+int triangleDirection = 1;
+
// Initialise display
SPInit gSpi(D_MOSI_PIN, NC, D_CLK_PIN);
Adafruit_SSD1306_Spi oled(gSpi, D_DC_PIN, D_RST_PIN, D_CS_PIN, 64, 128);
@@ -143,10 +145,10 @@ void square(void){
void triangle(void)
{
- amp++;
+ amp += triangleDirection;
out_wave = (float)amp / 100;
- if (amp == 100)
- amp = 0;
+ if (amp == 100 || amp == 0)
+ triangleDirection = triangleDirection*-1;
}
void sine(void)
@@ -156,3 +158,4 @@ void sine(void)
out_wave.write_u16(sineArray[amp]);
amp++;
}
+