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: SDFileSystem app epson mbed msp430 pl tests
pagetouch.cpp
00001 // 00002 // Filename: pagetouch.cpp 00003 // 00004 // Flexbook page for page A4. 00005 // 00006 00007 #include "pagetouch.h" 00008 #include "pageflexenable.h" 00009 00010 #include "eink.h" 00011 00012 #include "log.h" 00013 00014 #include <iostream> 00015 00016 namespace Flexbook { 00017 00018 PageTouch::PageTouch() 00019 : pageflexenable(), 00020 hangmangame(), 00021 i2c(p28, p27), irq(p26), 00022 at42qt2120(i2c), key(0) 00023 { 00024 Log("Creating PageTouch"); 00025 00026 00027 at42qt2120.SetSliderOptions(HAL::WHEEL); 00028 00029 at42qt2120.SetKeyControl(1, false, 2, false, true); 00030 at42qt2120.SetKeyControl(2, false, 2, false, true); 00031 at42qt2120.SetKeyControl(3, false, 2, false, true); 00032 00033 at42qt2120.SetKeyControl(5, false, 1, false, true); 00034 at42qt2120.SetKeyControl(6, false, 1, false, true); 00035 at42qt2120.SetKeyControl(7, false, 1, false, true); 00036 at42qt2120.SetKeyControl(8, false, 1, false, true); 00037 at42qt2120.SetKeyControl(9, false, 1, false, true); 00038 at42qt2120.SetKeyControl(10, false, 1, false, true); 00039 00040 irq.fall(callback(this, &Flexbook::PageTouch::TouchChange)); 00041 newtouch = false; 00042 imgnumber = 0; 00043 00044 #ifdef VERBOSE 00045 for(int n = 0; n < 99; n++) 00046 printf("Register %03d %02x\n", n, at42qt2120.Read((HAL::REG_AT42QT2120) n)); 00047 #endif 00048 } 00049 00050 PageTouch::~PageTouch() 00051 { 00052 Log("Deleting PageTouch"); 00053 00054 irq.disable_irq(); 00055 } 00056 00057 void PageTouch::TouchChange() 00058 { 00059 static volatile bool inirq = false; 00060 if(!inirq) 00061 { 00062 inirq = true; 00063 Page::ShortBeep(); 00064 00065 HAL::AT42QT2120::Status status; 00066 if(at42qt2120.ReadStatus(status)) 00067 { 00068 if(status.keyschanged) 00069 { 00070 key = status.keys; 00071 00072 if(status.keys & HAL::KEY0) 00073 Log("Key 0"); 00074 if(status.keys & HAL::KEY1) 00075 Log("Key 1"); 00076 if(status.keys & HAL::KEY2) 00077 Log("Key 2"); 00078 if(status.keys & HAL::KEY3) 00079 Log("Key 3"); 00080 if(status.keys & HAL::KEY4) 00081 Log("Key 4"); 00082 if(status.keys & HAL::KEY5) 00083 Log("Key 5"); 00084 if(status.keys & HAL::KEY6) 00085 { 00086 Log("Key 6"); 00087 hangmangame.currentpos = hangmangame.MoveCursor(hangmangame.alphabet, 6, hangmangame.oldpos); 00088 Log("back in pagetouch"); 00089 } 00090 if(status.keys & HAL::KEY7) 00091 { 00092 Log("Key 7"); 00093 hangmangame.currentpos = hangmangame.MoveCursor(hangmangame.alphabet, 7, hangmangame.oldpos); 00094 } 00095 if(status.keys & HAL::KEY8) 00096 { 00097 Log("Key 8"); 00098 } 00099 if(status.keys & HAL::KEY9) 00100 { 00101 Log("Key 9"); 00102 hangmangame.currentpos = hangmangame.MoveCursor(hangmangame.alphabet, 9, hangmangame.oldpos); 00103 } 00104 if(status.keys & HAL::KEY10) 00105 { 00106 Log("Key 10"); 00107 hangmangame.currentpos = hangmangame.MoveCursor(hangmangame.alphabet, 10, hangmangame.oldpos); 00108 } 00109 if(status.keys & HAL::KEY11) 00110 Log("Key 11"); 00111 } 00112 if(status.sliderchanged) 00113 { 00114 printf("Slider/wheel: %x\n", status.slider); 00115 } 00116 } 00117 00118 inirq = false; 00119 } 00120 } 00121 00122 int PageTouch::GetKey() 00123 { 00124 int outkey = key; 00125 key = 0; 00126 return outkey; 00127 } 00128 00129 /* 00130 void PageTouch::HandlePageActions() 00131 { 00132 if (newtouch) 00133 { 00134 printf("%i \n", imgnumber); 00135 pageflexenable.numimage = imgnumber; 00136 //pageflexenable.UpdateImage(); 00137 newtouch = false; 00138 } 00139 } 00140 */ 00141 } // End Flexbook namespace. 00142 00143 00144
Generated on Tue Jul 12 2022 18:36:26 by
1.7.2