Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Front/Front.cpp@8:f305ea78b2b1, 2020-05-05 (annotated)
- Committer:
- lukeocarwright
- Date:
- Tue May 05 16:46:01 2020 +0000
- Revision:
- 8:f305ea78b2b1
- Parent:
- 7:33cb5f2db1ee
- Child:
- 13:27300c533dd1
Added Sliders to Faders ready for GUI.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lukeocarwright | 7:33cb5f2db1ee | 1 | #include "mbed.h" |
lukeocarwright | 7:33cb5f2db1ee | 2 | #include "Front.h" |
lukeocarwright | 8:f305ea78b2b1 | 3 | //objects |
lukeocarwright | 7:33cb5f2db1ee | 4 | |
lukeocarwright | 7:33cb5f2db1ee | 5 | const int fader[35][5] = { |
lukeocarwright | 7:33cb5f2db1ee | 6 | { 1,1,1,1,1 }, |
lukeocarwright | 7:33cb5f2db1ee | 7 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 8 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 9 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 10 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 11 | { 1,1,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 12 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 13 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 14 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 15 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 16 | { 1,1,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 17 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 18 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 19 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 20 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 21 | { 1,1,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 22 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 23 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 24 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 25 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 26 | { 1,1,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 27 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 28 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 29 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 30 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 31 | { 1,1,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 32 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 33 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 34 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 35 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 36 | { 1,1,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 37 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 38 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 39 | { 0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 40 | { 1,1,1,1,1 }, |
lukeocarwright | 7:33cb5f2db1ee | 41 | }; |
lukeocarwright | 7:33cb5f2db1ee | 42 | |
lukeocarwright | 7:33cb5f2db1ee | 43 | const int sin_wav[6][28] = {//sub 1 |
lukeocarwright | 7:33cb5f2db1ee | 44 | { 0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 45 | { 0,1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 46 | { 1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 47 | { 0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1 }, |
lukeocarwright | 7:33cb5f2db1ee | 48 | { 0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 49 | { 0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 50 | }; |
lukeocarwright | 7:33cb5f2db1ee | 51 | const int tri_wav[6][28] = {//sub 2 |
lukeocarwright | 7:33cb5f2db1ee | 52 | { 0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 53 | { 0,0,1,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 54 | { 0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 55 | { 1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 56 | { 0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,1 }, |
lukeocarwright | 7:33cb5f2db1ee | 57 | { 0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 58 | }; |
lukeocarwright | 7:33cb5f2db1ee | 59 | const int square_wav[6][28] = {//sub 3 |
lukeocarwright | 7:33cb5f2db1ee | 60 | { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 61 | { 1,1,1,1,1,0,0,0,1,1,1,1,1,0,0,0,1,1,1,1,1,0,0,0,1,1,1,1 }, |
lukeocarwright | 7:33cb5f2db1ee | 62 | { 0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 63 | { 0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 64 | { 0,0,0,0,1,1,1,1,1,0,0,0,1,1,1,1,1,0,0,0,1,1,1,1,1,0,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 65 | { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }, |
lukeocarwright | 7:33cb5f2db1ee | 66 | }; |
lukeocarwright | 7:33cb5f2db1ee | 67 | //constructor/destructor |
lukeocarwright | 7:33cb5f2db1ee | 68 | Front::Front() |
lukeocarwright | 7:33cb5f2db1ee | 69 | { |
lukeocarwright | 7:33cb5f2db1ee | 70 | } |
lukeocarwright | 7:33cb5f2db1ee | 71 | Front::~Front() |
lukeocarwright | 7:33cb5f2db1ee | 72 | { |
lukeocarwright | 7:33cb5f2db1ee | 73 | } |
lukeocarwright | 7:33cb5f2db1ee | 74 | //PUBLIC------------------------------------------------------------------------ |
lukeocarwright | 8:f305ea78b2b1 | 75 | |
lukeocarwright | 8:f305ea78b2b1 | 76 | void Front::frontrun(N5110 &lcd, Gamepad &pad, int submenu) |
lukeocarwright | 8:f305ea78b2b1 | 77 | { |
lukeocarwright | 8:f305ea78b2b1 | 78 | frontsetup(lcd, pad, submenu); |
lukeocarwright | 8:f305ea78b2b1 | 79 | menuflag=1; |
lukeocarwright | 8:f305ea78b2b1 | 80 | while (menuflag==1) { |
lukeocarwright | 8:f305ea78b2b1 | 81 | if (pad.start_pressed()) { //go back menu |
lukeocarwright | 8:f305ea78b2b1 | 82 | // printf("start pressed\n"); |
lukeocarwright | 8:f305ea78b2b1 | 83 | printf("Waveforms Sub selected\n"); //debug |
lukeocarwright | 8:f305ea78b2b1 | 84 | wait_ms(200); //debounce |
lukeocarwright | 8:f305ea78b2b1 | 85 | menuflag=0; //sets flag |
lukeocarwright | 8:f305ea78b2b1 | 86 | } |
lukeocarwright | 8:f305ea78b2b1 | 87 | } |
lukeocarwright | 8:f305ea78b2b1 | 88 | } |
lukeocarwright | 8:f305ea78b2b1 | 89 | |
lukeocarwright | 8:f305ea78b2b1 | 90 | |
lukeocarwright | 8:f305ea78b2b1 | 91 | //PRIVATE----------------------------------------------------------------------- |
lukeocarwright | 8:f305ea78b2b1 | 92 | |
lukeocarwright | 7:33cb5f2db1ee | 93 | void Front::frontsetup(N5110 &lcd, Gamepad &pad, int submenu) |
lukeocarwright | 7:33cb5f2db1ee | 94 | { |
lukeocarwright | 8:f305ea78b2b1 | 95 | a=17; //range from 1->35 |
lukeocarwright | 8:f305ea78b2b1 | 96 | d=17; |
lukeocarwright | 8:f305ea78b2b1 | 97 | s=17; |
lukeocarwright | 8:f305ea78b2b1 | 98 | r=17; |
lukeocarwright | 7:33cb5f2db1ee | 99 | lcd.clear(); |
lukeocarwright | 7:33cb5f2db1ee | 100 | lcd.printString("A D S R",3,5); |
lukeocarwright | 7:33cb5f2db1ee | 101 | printfader(lcd,3,3); |
lukeocarwright | 7:33cb5f2db1ee | 102 | printfader(lcd,15,3); |
lukeocarwright | 7:33cb5f2db1ee | 103 | printfader(lcd,27,3); |
lukeocarwright | 7:33cb5f2db1ee | 104 | printfader(lcd,39,3); |
lukeocarwright | 7:33cb5f2db1ee | 105 | lcd.drawRect(50,3,30,8,FILL_TRANSPARENT); |
lukeocarwright | 7:33cb5f2db1ee | 106 | printwav(lcd,submenu); |
lukeocarwright | 8:f305ea78b2b1 | 107 | printsliders(lcd,a,d,s,r); |
lukeocarwright | 7:33cb5f2db1ee | 108 | lcd.refresh(); |
lukeocarwright | 8:f305ea78b2b1 | 109 | |
lukeocarwright | 7:33cb5f2db1ee | 110 | } |
lukeocarwright | 8:f305ea78b2b1 | 111 | void Front::printsliders(N5110 &lcd, int a, int d, int s, int r) |
lukeocarwright | 7:33cb5f2db1ee | 112 | { |
lukeocarwright | 8:f305ea78b2b1 | 113 | lcd.drawRect(3,37-a,5,2,FILL_BLACK); |
lukeocarwright | 8:f305ea78b2b1 | 114 | lcd.drawRect(15,37-d,5,2,FILL_BLACK); |
lukeocarwright | 8:f305ea78b2b1 | 115 | lcd.drawRect(27,37-s,5,2,FILL_BLACK); |
lukeocarwright | 8:f305ea78b2b1 | 116 | lcd.drawRect(39,37-r,5,2,FILL_BLACK); |
lukeocarwright | 7:33cb5f2db1ee | 117 | } |
lukeocarwright | 7:33cb5f2db1ee | 118 | void Front::printfader(N5110 &lcd, int x, int y) |
lukeocarwright | 7:33cb5f2db1ee | 119 | { |
lukeocarwright | 7:33cb5f2db1ee | 120 | // x origin, y origin, rows, cols, sprite |
lukeocarwright | 7:33cb5f2db1ee | 121 | lcd.drawSprite(x,y,35,5,(int *)fader); |
lukeocarwright | 7:33cb5f2db1ee | 122 | } |
lukeocarwright | 7:33cb5f2db1ee | 123 | |
lukeocarwright | 7:33cb5f2db1ee | 124 | void Front::printwav(N5110 &lcd, int submenu) |
lukeocarwright | 7:33cb5f2db1ee | 125 | { |
lukeocarwright | 7:33cb5f2db1ee | 126 | if (submenu==1) { |
lukeocarwright | 7:33cb5f2db1ee | 127 | // x origin, y origin, rows, cols, sprite |
lukeocarwright | 7:33cb5f2db1ee | 128 | lcd.drawSprite(51,4,6,28,(int *)sin_wav); |
lukeocarwright | 7:33cb5f2db1ee | 129 | } |
lukeocarwright | 7:33cb5f2db1ee | 130 | if (submenu==2) { |
lukeocarwright | 7:33cb5f2db1ee | 131 | // x origin, y origin, rows, cols, sprite |
lukeocarwright | 7:33cb5f2db1ee | 132 | lcd.drawSprite(51,4,6,28,(int *)tri_wav); |
lukeocarwright | 7:33cb5f2db1ee | 133 | } |
lukeocarwright | 7:33cb5f2db1ee | 134 | if (submenu==3) { |
lukeocarwright | 7:33cb5f2db1ee | 135 | // x origin, y origin, rows, cols, sprite |
lukeocarwright | 7:33cb5f2db1ee | 136 | lcd.drawSprite(51,4,6,28,(int *)square_wav); |
lukeocarwright | 7:33cb5f2db1ee | 137 | } |
lukeocarwright | 7:33cb5f2db1ee | 138 | } |