diff options
author | Waleed El-Geresy <waleed.el-geresy15@imperial.ac.uk> | 2017-05-11 09:41:03 +0100 |
---|---|---|
committer | Vasil Zlatanov <v@skozl.com> | 2017-05-11 09:49:10 +0100 |
commit | 1c721a5b2c7f4540c2b67a6b6dbef97427312d85 (patch) | |
tree | 9d62bbc210cdb58412d54e5776b8d55d3ec2e92a /src | |
parent | aa402760fb91529f6e75e15959a18bd2070562a2 (diff) | |
download | e2-switch-master.tar.gz e2-switch-master.tar.bz2 e2-switch-master.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/main.cpp | 9 |
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++; } + |