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: SPI_STMPE610 UniGraphic mbed vt100
menu.cpp
00001 /** mbed oscilloscope my implementation of a oscillo scope 00002 * Copyright (c) 2014, 2015 Motoo Tanaka @ Design Methodology Lab 00003 * 00004 * menu.cpp 00005 * 00006 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00007 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00008 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00009 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00010 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00011 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00012 * THE SOFTWARE. 00013 */ 00014 #include "mbed.h" 00015 #include <ILI9341.h> 00016 #include "SPI_STMPE610.h" 00017 #include "Arial12x12.h" 00018 #include "Arial24x23.h" 00019 #include "Arial28x28.h" 00020 #include "Arial43x48_numb.h" 00021 #include "vt100.h" 00022 #include "TFTMenu.h" 00023 #include "menu.h" 00024 #include "trig.h" 00025 #include "view.h" 00026 #include "main.h" 00027 00028 void doubleTime(void) 00029 { 00030 if (mode == MODE_RUN) { 00031 timer.detach() ; 00032 } 00033 envChanged() ; 00034 us_interval *= 2 ; 00035 if (us_interval > MAX_INTERVAL) { 00036 us_interval = MAX_INTERVAL ; 00037 } 00038 printTimeDiv() ; 00039 if (mode == MODE_RUN) { 00040 timer.attach_us(&sampleAD, us_interval) ; 00041 } 00042 } 00043 00044 void halfTime(void) 00045 { 00046 if (mode == MODE_RUN) { 00047 timer.detach() ; 00048 } 00049 envChanged() ; 00050 us_interval /= 2 ; 00051 if (us_interval < MIN_INTERVAL) { 00052 us_interval = MIN_INTERVAL ; 00053 } 00054 printTimeDiv() ; 00055 if (mode == MODE_RUN) { 00056 timer.attach_us(&sampleAD, us_interval) ; 00057 } 00058 } 00059 00060 void doStart(void) 00061 { 00062 if (mode == MODE_RUN) { 00063 mode = MODE_STOP ; 00064 timer.detach() ; 00065 printMode() ; 00066 } else { 00067 mode = MODE_RUN ; 00068 printMode() ; 00069 timer.attach_us(&sampleAD, us_interval) ; 00070 } 00071 00072 } 00073 00074 void doubleAmp(void) 00075 { 00076 } 00077 00078 void halfAmp(void) 00079 { 00080 } 00081 00082 void doTrigger(void) 00083 { 00084 trig_mode = (trig_mode + 1) % NUM_TRIG_MODE ; 00085 drawTrigMark() ; 00086 printTrigMode() ; 00087 } 00088 00089 void doStop(void) 00090 { 00091 timer.detach() ; 00092 mode = MODE_STOP ; 00093 printMode() ; 00094 } 00095 00096 void TrigLevelDown(void) 00097 { 00098 trig_level -= 0.1 ; 00099 if (trig_level < 0.0) { 00100 trig_level = 0.0 ; 00101 } 00102 printTrigLevel() ; 00103 } 00104 00105 void TrigLevelUp(void) 00106 { 00107 trig_level += 0.1 ; 00108 if (trig_level > vref) { 00109 trig_level = vref ; 00110 } 00111 printTrigLevel() ; 00112 } 00113 00114 void initMenu(void) 00115 { 00116 numMenu = 0 ; 00117 menu[numMenu++] = new TFTRadioButton( 20, 190, 60, 220, doStart, "Run", Blue, White, "Stop", Red, White, true) ; 00118 // menu[numMenu++] = new TFTMenuItem(180, 180, 220, 210, doStop, "Stop", Red, White) ; 00119 menu[numMenu++] = new TFTMenuItem( 20, 230, 55, 260, doubleTime, "1/2", Blue, White) ; 00120 menu[numMenu++] = new TFTMenuItem(180, 230, 215, 260, halfTime, "x2", Blue, White) ; 00121 menu[numMenu++] = new TFTMenuItem( 20, 270, 60, 300, doTrigger, "Trig", Green, Black) ; 00122 // menu[numMenu++] = new TFTMenuItem(170, 260, 190, 290, TrigLevelUp, "^", Blue, White) ; 00123 // menu[numMenu++] = new TFTMenuItem(200, 260, 220, 290, TrigLevelDown, "V", Blue, White) ; 00124 00125 } 00126 00127 void drawMenu(void) 00128 { 00129 for (int i = 0 ; i < numMenu ; i++ ) { 00130 menu[i]->draw() ; 00131 } 00132 printMode() ; 00133 printTimeDiv() ; 00134 printTrigMode() ; 00135 } 00136 00137 bool doMenu(uint16_t x, uint16_t y) 00138 { 00139 bool result = false ; 00140 /* 00141 if ((x == 0)&&(y ==0)) { 00142 return 00143 } 00144 */ 00145 for (int i = 0 ; i < numMenu ; i++ ) { 00146 if (menu[i]->hit(x, y)) { 00147 // menu[i]->highlight() ; 00148 menu[i]->doIt() ; 00149 menu[i]->draw() ; 00150 result = true ; 00151 break ; 00152 } 00153 } 00154 return( result ) ; 00155 }
Generated on Wed Jul 13 2022 01:48:09 by
