Arduino  1.8.10
VirtualKeyboard クラス

#include <VirtualKeyboard.h>

公開メンバ関数

void display (uint8_t top, uint16_t showColor=BLACK, uint16_t hideColor=WHITE)
 
void hide ()
 
char getSelection ()
 
void run ()
 

詳解

VirtualKeyboard.h7 行目に定義があります。

関数詳解

◆ display()

void VirtualKeyboard::display ( uint8_t  top,
uint16_t  showColor = BLACK,
uint16_t  hideColor = WHITE 
)

Display the keyboard at y position of top formular: When text size is 1, one character is 5*7 margin-left==margin-right==3, margin-top==margin-bottom==2, keyWidth=5+3+3==11, keyHeight=7+2+2==11, keyboard-margin-left=keyboard-margin-right==9 so character-x=11*col+9+3=11*col+12 character-y=11*lin+2+top

VirtualKeyboard.cpp74 行目に定義があります。

74  {
75 /** Display the keyboard at y position of top
76 * formular:
77 * When text size is 1, one character is 5*7
78 * margin-left==margin-right==3,
79 * margin-top==margin-bottom==2,
80 * keyWidth=5+3+3==11,
81 * keyHeight=7+2+2==11,
82 * keyboard-margin-left=keyboard-margin-right==9
83 * so character-x=11*col+9+3=11*col+12
84 * character-y=11*lin+2+top
85 *
86 **/
87  this->top=top;
88  this->onOff=true;
89 
90  this->showColor=showColor;
91  this->hideColor=hideColor;
92 
93  for(uint8_t i=0;i<36;i++){
94  Robot.setCursor(i%10*11+12,2+top+i/10*11);
95  if(i<10)
96  Robot.print(char('0'+i));
97  else
98  Robot.print(char(55+i));//'A'-10=55
99  }//for saving 58 bytes :(
100 
101  /*for(int i=0;i<10;i++){
102  Robot.setCursor(i*11+12,2+top);//11*0+2+top
103  Robot.print(char('0'+i));//line_1: 0-9
104  }
105  for(int i=0;i<10;i++){
106  Robot.setCursor(i*11+12,13+top);//11*1+2+top
107  Robot.print(char('A'+i));//line_2: A-J
108  }
109  for(int i=0;i<10;i++){
110  Robot.setCursor(i*11+12,24+top);//11*2+2+top
111  Robot.print(char('K'+i));//line_3: K-T
112  }
113  for(int i=0;i<6;i++){
114  Robot.setCursor(i*11+12,35+top);//11*3+2+top
115  Robot.print(char('U'+i));//line_4: U-Z
116  }*/
117  //space and enter at the end of the last line.
118  Robot.setCursor(78,35+top);//6*11+12=78
119  Robot.print('_');//_
120 
121  Robot.setCursor(89,35+top);//7*11+12=89
122  Robot.print("Enter");//enter
123 }
uint8_t i
RobotControl Robot
size_t print(const __FlashStringHelper *)
Definition: Print.cpp:44
void setCursor(int16_t x, int16_t y)

◆ getSelection()

char VirtualKeyboard::getSelection ( )

VirtualKeyboard.cpp54 行目に定義があります。

54  {
55  if(!onOff)return -1;
56 
57  uint8_t val=map(Robot.knobRead(),0,1023,0,38);
58  if(0<=val && 9>=val)
59  val='0'+val;
60  else if(10<=val && 35>=val)
61  val='A'+val-10;
62  else if(val==36)
63  val=' ';
64  else if(val>=37)
65  val='\0';
66 
67  return val;
68 }
long map(long x, long in_min, long in_max, long out_min, long out_max)
Definition: WMath.cpp:52
int knobRead()
Definition: Sensors.cpp:253
RobotControl Robot

◆ hide()

void VirtualKeyboard::hide ( )

VirtualKeyboard.cpp69 行目に定義があります。

69  {
70  onOff=false;
71  Robot.fillRect(0,top,128,44,hideColor);//11*4
72 }
RobotControl Robot
void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)

◆ run()

void VirtualKeyboard::run ( )

visually select a letter on the keyboard The selection boarder is 1px higher than the character, 1px on the bottom, 2px to the left and 2px to the right.

VirtualKeyboard.cpp22 行目に定義があります。

22  {
23 /** visually select a letter on the keyboard
24 * The selection boarder is 1px higher than the character,
25 * 1px on the bottom, 2px to the left and 2px to the right.
26 *
27 */
28  if(!onOff)return;
29  //Serial.println(onOff);
30  static int oldColLin=0;
31  uint8_t val=map(Robot.knobRead(),0,1023,0,38);
32  if(val==38)val=37; //The last value is jumpy when using batteries
33  int colLin=getColLin(val);
34 
35  if(oldColLin!=colLin){
36  uint8_t x=(oldColLin>>8 & 0xFF)*11+10;//col*11+1+9
37  uint8_t y=(oldColLin & 0xFF)*11+1+top;//lin*11+1+top
38  uint8_t w=9;
39  if(oldColLin==1795) //last item "Enter", col=7 lin=3
40  w=33; //(5+1)*6-1+2+2 charWidth=5, charMargin=1, count("Enter")=6, lastItem_MarginRight=0, marginLeft==marginRight=2
41  Robot.drawRect(x,y,w,9,hideColor);
42 
43 
44  x=(colLin>>8 & 0xFF)*11+10;
45  y=(colLin & 0xFF)*11+1+top;
46  w=9;
47  if(colLin==1795) //last item "Enter", col=7 lin=3
48  w=33; //(5+1)*6-1+2+2 charWidth=5, charMargin=1, count("Enter")=6, lastItem_MarginRight=0, marginLeft==marginRight=2
49  Robot.drawRect(x,y,w,9,showColor);
50  oldColLin=colLin;
51  }
52 }
long map(long x, long in_min, long in_max, long out_min, long out_max)
Definition: WMath.cpp:52
int knobRead()
Definition: Sensors.cpp:253
RobotControl Robot
virtual void drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)

このクラス詳解は次のファイルから抽出されました: