Changeset 822
- Timestamp:
- 06/27/07 17:20:02 (17 months ago)
- Location:
- branches/volker_dev
- Files:
-
- 4 modified
-
drv_X11.c (modified) (8 diffs)
-
drv_generic_graphic.c (modified) (1 diff)
-
evaluator.c (modified) (19 diffs)
-
lcd4linux.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/volker_dev/drv_X11.c
r819 r822 140 140 int i; 141 141 float dim; 142 142 143 143 /* -1 is used to query the current brightness */ 144 144 if (brightness == -1) 145 145 return Brightness; 146 146 147 147 if (brightness < 0) 148 148 brightness = 0; 149 149 if (brightness > 255) 150 150 brightness = 255; 151 151 152 152 if (Brightness != brightness) { 153 Brightness = brightness;154 dim = Brightness / 255.0;155 col.R *= dim;156 col.G *= dim;157 col.B *= dim;158 159 debug("%s: set backlight to %d%%, original backlight color: 0x%02x%02x%02x%02x, dimmed: 0x%02x%02x%02x%02x",160 Name, (int)(dim * 100), BL_COL.R, BL_COL.G, BL_COL.B, BL_COL.A, col.R, col.G, col.B, col.A);161 for (i = 0; i < DCOLS * DROWS; i++) {162 drv_X11_FB[i] = col;163 }164 165 drv_X11_color(col);166 167 XFillRectangle(dp, pm, gc, 0, 0, dimx + 2 * border + btnwidth, dimy + 2 * border);168 XSetWindowBackground(dp, w, xc.pixel);169 XClearWindow(dp, w);170 171 /* redraw every LCD pixel */172 drv_X11_blit(0, 0, LROWS, LCOLS);153 Brightness = brightness; 154 dim = Brightness / 255.0; 155 col.R *= dim; 156 col.G *= dim; 157 col.B *= dim; 158 159 debug("%s: set backlight to %d%%, original backlight color: 0x%02x%02x%02x%02x, dimmed: 0x%02x%02x%02x%02x", 160 Name, (int) (dim * 100), BL_COL.R, BL_COL.G, BL_COL.B, BL_COL.A, col.R, col.G, col.B, col.A); 161 for (i = 0; i < DCOLS * DROWS; i++) { 162 drv_X11_FB[i] = col; 163 } 164 165 drv_X11_color(col); 166 167 XFillRectangle(dp, pm, gc, 0, 0, dimx + 2 * border + btnwidth, dimy + 2 * border); 168 XSetWindowBackground(dp, w, xc.pixel); 169 XClearWindow(dp, w); 170 171 /* redraw every LCD pixel */ 172 drv_X11_blit(0, 0, LROWS, LCOLS); 173 173 } 174 174 … … 180 180 { 181 181 int val = WIDGET_KEY_PRESSED; 182 182 183 183 switch (num) { 184 case 1:185 val += WIDGET_KEY_UP;186 break;187 case 2:188 val += WIDGET_KEY_DOWN;189 break;190 case 3:191 val += WIDGET_KEY_LEFT;192 break;193 case 4:194 val += WIDGET_KEY_RIGHT;195 break;196 case 5:197 val += WIDGET_KEY_CONFIRM;198 break;199 case 6:200 val += WIDGET_KEY_CANCEL;201 break;202 default:203 error("%s: unknown keypad value %d", Name, num);204 } 205 184 case 1: 185 val += WIDGET_KEY_UP; 186 break; 187 case 2: 188 val += WIDGET_KEY_DOWN; 189 break; 190 case 3: 191 val += WIDGET_KEY_LEFT; 192 break; 193 case 4: 194 val += WIDGET_KEY_RIGHT; 195 break; 196 case 5: 197 val += WIDGET_KEY_CONFIRM; 198 break; 199 case 6: 200 val += WIDGET_KEY_CANCEL; 201 break; 202 default: 203 error("%s: unknown keypad value %d", Name, num); 204 } 205 206 206 debug("%s: key %c (0x%x) pressed", Name, num, num); 207 207 return val; … … 228 228 char *s; 229 229 char unknownTxt[10]; 230 230 231 231 x0 = x - pixel; 232 232 x1 = x + pixel + width; … … 246 246 } 247 247 } 248 248 249 249 /* Keypad on the right side */ 250 250 if (x1 >= xoffset) { 251 xfs = XQueryFont(dp, XGContextFromGC(DefaultGC(dp, 0)));252 if (drv_X11_brightness(-1) > 127) {253 drv_X11_color(FG_COL);254 } else {255 drv_X11_color(BG_COL);256 }257 for (r = 0; r < buttons; r++) {258 yk = yoffset + r * (btnheight + pgap);259 switch(r) {260 case 0:261 s = "Up";262 break;263 case 1:264 s = "Down";265 break;266 case 2:267 s = "Left";268 break;269 case 3:270 s = "Right";271 break;272 case 4:273 s = "Confirm";274 break;275 case 5:276 s = "Cancel";277 break;278 default:279 snprintf(unknownTxt, sizeof(unknownTxt), "#%d??", r);280 s = unknownTxt;281 }282 XDrawRectangle(dp, w, gc, xoffset, yk, btnwidth, btnheight - 2);283 XDrawString(dp, w, gc,284 xoffset + btnwidth / 2 - (xfs->max_bounds.width * strlen(s)) / 2, yk + btnheight / 2 + xfs->max_bounds.ascent/ 2,285 s, strlen(s)); 286 }287 } 288 //XSync(dp, False);251 xfs = XQueryFont(dp, XGContextFromGC(DefaultGC(dp, 0))); 252 if (drv_X11_brightness(-1) > 127) { 253 drv_X11_color(FG_COL); 254 } else { 255 drv_X11_color(BG_COL); 256 } 257 for (r = 0; r < buttons; r++) { 258 yk = yoffset + r * (btnheight + pgap); 259 switch (r) { 260 case 0: 261 s = "Up"; 262 break; 263 case 1: 264 s = "Down"; 265 break; 266 case 2: 267 s = "Left"; 268 break; 269 case 3: 270 s = "Right"; 271 break; 272 case 4: 273 s = "Confirm"; 274 break; 275 case 5: 276 s = "Cancel"; 277 break; 278 default: 279 snprintf(unknownTxt, sizeof(unknownTxt), "#%d??", r); 280 s = unknownTxt; 281 } 282 XDrawRectangle(dp, w, gc, xoffset, yk, btnwidth, btnheight - 2); 283 XDrawString(dp, w, gc, 284 xoffset + btnwidth / 2 - (xfs->max_bounds.width * strlen(s)) / 2, 285 yk + btnheight / 2 + xfs->max_bounds.ascent / 2, s, strlen(s)); 286 } 287 } 288 //XSync(dp, False); 289 289 } 290 290 … … 297 297 int yoffset = border + (DROWS / YRES) * rgap; 298 298 static int btn = 0; 299 299 300 300 if (XCheckWindowEvent(dp, w, ExposureMask | ButtonPressMask | ButtonReleaseMask, &ev) == 0) 301 301 return; 302 switch(ev.type) { 303 case Expose: 304 drv_X11_expose(ev.xexpose.x, ev.xexpose.y, ev.xexpose.width, ev.xexpose.height); 305 break; 306 case ButtonPress: 307 if ( ev.xbutton.x >= xoffset && ev.xbutton.x <= xoffset + btnwidth 308 && ev.xbutton.y >= yoffset && ev.xbutton.y <= yoffset + buttons * btnheight + (buttons -1 ) *pgap ) { 309 btn = (ev.xbutton.y - yoffset) / (btnheight + pgap) + 1; /* btn 0 is unused */ 310 drv_X11_color(BG_COL); 311 XFillRectangle(dp, w, gc, xoffset + 1, yoffset + (btn - 1) * (btnheight + pgap) + 1, btnwidth - 1, btnheight - 2 - 1); 312 drv_generic_keypad_press(btn); 313 } 314 break; 315 case ButtonRelease: 316 if ( ev.xbutton.x >= xoffset && ev.xbutton.x <= xoffset + btnwidth 317 && ev.xbutton.y >= yoffset && ev.xbutton.y <= yoffset + buttons * btnheight + (buttons -1 ) *pgap ) { 318 XClearArea(dp, w, xoffset, yoffset + (btn - 1) * (btnheight + pgap), btnwidth, btnheight - 2, 1 /* true */); 319 btn = (ev.xbutton.y - yoffset) / (btnheight + pgap) + 1; /* btn 0 is unused */ 320 info("%s: Button %d released", Name, btn); 321 } 322 break; 323 default: 324 debug("%s: unknown XEvent %d", Name, ev.type); 302 switch (ev.type) { 303 case Expose: 304 drv_X11_expose(ev.xexpose.x, ev.xexpose.y, ev.xexpose.width, ev.xexpose.height); 305 break; 306 case ButtonPress: 307 if (ev.xbutton.x >= xoffset && ev.xbutton.x <= xoffset + btnwidth 308 && ev.xbutton.y >= yoffset && ev.xbutton.y <= yoffset + buttons * btnheight + (buttons - 1) * pgap) { 309 btn = (ev.xbutton.y - yoffset) / (btnheight + pgap) + 1; /* btn 0 is unused */ 310 drv_X11_color(BG_COL); 311 XFillRectangle(dp, w, gc, xoffset + 1, yoffset + (btn - 1) * (btnheight + pgap) + 1, btnwidth - 1, 312 btnheight - 2 - 1); 313 drv_generic_keypad_press(btn); 314 } 315 break; 316 case ButtonRelease: 317 if (ev.xbutton.x >= xoffset && ev.xbutton.x <= xoffset + btnwidth 318 && ev.xbutton.y >= yoffset && ev.xbutton.y <= yoffset + buttons * btnheight + (buttons - 1) * pgap) { 319 XClearArea(dp, w, xoffset, yoffset + (btn - 1) * (btnheight + pgap), btnwidth, btnheight - 2, 320 1 /* true */ ); 321 btn = (ev.xbutton.y - yoffset) / (btnheight + pgap) + 1; /* btn 0 is unused */ 322 info("%s: Button %d released", Name, btn); 323 } 324 break; 325 default: 326 debug("%s: unknown XEvent %d", Name, ev.type); 325 327 } 326 328 } … … 378 380 } 379 381 free(s); 380 382 381 383 /* virtual keyboard: number of buttons (0..6) */ 382 384 if (cfg_number(section, "buttons", 0, 0, 6, &buttons) < 0) 383 return -1;385 return -1; 384 386 385 387 drv_X11_FB = malloc(DCOLS * DROWS * sizeof(*drv_X11_FB)); … … 462 464 { 463 465 double brightness; 464 466 465 467 switch (argc) { 466 case 0:467 brightness = drv_X11_brightness(-1);468 SetResult(&result, R_NUMBER, &brightness);469 break;470 case 1:471 brightness = drv_X11_brightness(R2N(argv[0]));472 SetResult(&result, R_NUMBER, &brightness);473 break;474 default:475 error("%s.brightness(): wrong number of parameters", Name);476 SetResult(&result, R_STRING, "");468 case 0: 469 brightness = drv_X11_brightness(-1); 470 SetResult(&result, R_NUMBER, &brightness); 471 break; 472 case 1: 473 brightness = drv_X11_brightness(R2N(argv[0])); 474 SetResult(&result, R_NUMBER, &brightness); 475 break; 476 default: 477 error("%s.brightness(): wrong number of parameters", Name); 478 SetResult(&result, R_STRING, ""); 477 479 } 478 480 } … … 514 516 if ((ret = drv_generic_keypad_init(section, Name)) != 0) 515 517 return ret; 516 518 517 519 drv_generic_graphic_clear(); 518 520 -
branches/volker_dev/drv_generic_graphic.c
r815 r822 189 189 /* Layer 0 is topmost: Find lowest opaque layer */ 190 190 for (l = 0; l < LAYERS; l++) { 191 if (drv_generic_graphic_FB[l][row * LCOLS + col].A >= 255) {192 /* Layers below are fully covered */193 opaqueBottomLayer = l;194 break;195 }191 if (drv_generic_graphic_FB[l][row * LCOLS + col].A >= 255) { 192 /* Layers below are fully covered */ 193 opaqueBottomLayer = l; 194 break; 195 } 196 196 } 197 197 for (l = opaqueBottomLayer; l >= 0; l--) { -
branches/volker_dev/evaluator.c
r820 r822 989 989 argc = Root->Children; 990 990 if (argc > 10) { 991 error("evaluator: more than 10 children (operands) not supported!");991 error("evaluator: more than 10 children (operands) not supported!"); 992 992 argc = 10; 993 }993 } 994 994 for (i = 0; i < argc; i++) { 995 EvalTree(Root->Child[i]);995 EvalTree(Root->Child[i]); 996 996 param[i] = Root->Child[i]->Result; 997 997 } … … 1011 1011 case O_LST: /* expression list: result is last expression */ 1012 1012 i = Root->Children - 1; 1013 EvalTree(Root->Child[i]);1013 EvalTree(Root->Child[i]); 1014 1014 type = Root->Child[i]->Result->type; 1015 1015 number = Root->Child[i]->Result->number; … … 1018 1018 1019 1019 case O_SET: /* variable assignment */ 1020 EvalTree(Root->Child[0]);1020 EvalTree(Root->Child[0]); 1021 1021 CopyResult(&Root->Variable->value, Root->Child[0]->Result); 1022 1022 type = Root->Child[0]->Result->type; … … 1026 1026 1027 1027 case O_CND: /* conditional expression */ 1028 EvalTree(Root->Child[0]);1028 EvalTree(Root->Child[0]); 1029 1029 i = 1 + (R2N(Root->Child[0]->Result) == 0.0); 1030 EvalTree(Root->Child[i]);1030 EvalTree(Root->Child[i]); 1031 1031 type = Root->Child[i]->Result->type; 1032 1032 number = Root->Child[i]->Result->number; … … 1036 1036 case O_OR: /* logical OR */ 1037 1037 type = R_NUMBER; 1038 EvalTree(Root->Child[0]); 1039 if (R2N(Root->Child[0]->Result) == 0.0) { 1040 /* calculate 2nd operator only, if 1st operator is false */ 1041 EvalTree(Root->Child[1]); 1042 } 1043 number = ((R2N(Root->Child[0]->Result) != 0.0) || (R2N(Root->Child[1]->Result) != 0.0)); 1038 EvalTree(Child[0]); 1039 if (R2N(Root->Child[0]->Result) == 0.0) { 1040 EvalTree(Child[1]) 1041 number = (Child[1]->Result != 0.0); 1042 } else { 1043 number = 1.0; 1044 } 1044 1045 break; 1045 1046 1046 1047 case O_AND: /* logical AND */ 1047 1048 type = R_NUMBER; 1048 EvalTree(Root->Child[0]); 1049 if (R2N(Root->Child[0]->Result) != 0.0) { 1050 /* calculate 2nd operator only, if 1st operator is true */ 1051 EvalTree(Root->Child[1]); 1052 } 1053 number = ((R2N(Root->Child[0]->Result) != 0.0) && (R2N(Root->Child[1]->Result) != 0.0)); 1049 EvalTree(Root->Child[0]); 1050 if (R2N(Root->Child[0]->Result) != 0.0) { 1051 EvalTree(Child[1]) 1052 number = (Child[1]->Result != 0.0); 1053 } else { 1054 number = 0.0; 1055 } 1054 1056 break; 1055 1057 1056 1058 case O_EQ: /* numeric equal */ 1057 1059 type = R_NUMBER; 1058 EvalTree(Root->Child[0]);1059 EvalTree(Root->Child[1]);1060 EvalTree(Root->Child[0]); 1061 EvalTree(Root->Child[1]); 1060 1062 number = (R2N(Root->Child[0]->Result) == R2N(Root->Child[1]->Result)); 1061 1063 break; … … 1063 1065 case O_NE: /* numeric not equal */ 1064 1066 type = R_NUMBER; 1065 EvalTree(Root->Child[0]);1066 EvalTree(Root->Child[1]);1067 EvalTree(Root->Child[0]); 1068 EvalTree(Root->Child[1]); 1067 1069 number = (R2N(Root->Child[0]->Result) != R2N(Root->Child[1]->Result)); 1068 1070 break; … … 1070 1072 case O_LT: /* numeric less than */ 1071 1073 type = R_NUMBER; 1072 EvalTree(Root->Child[0]);1073 EvalTree(Root->Child[1]);1074 EvalTree(Root->Child[0]); 1075 EvalTree(Root->Child[1]); 1074 1076 number = (R2N(Root->Child[0]->Result) < R2N(Root->Child[1]->Result)); 1075 1077 break; … … 1077 1079 case O_LE: /* numeric less equal */ 1078 1080 type = R_NUMBER; 1079 EvalTree(Root->Child[0]);1080 EvalTree(Root->Child[1]);1081 EvalTree(Root->Child[0]); 1082 EvalTree(Root->Child[1]); 1081 1083 number = (R2N(Root->Child[0]->Result) <= R2N(Root->Child[1]->Result)); 1082 1084 break; … … 1084 1086 case O_GT: /* numeric greater than */ 1085 1087 type = R_NUMBER; 1086 EvalTree(Root->Child[0]);1087 EvalTree(Root->Child[1]);1088 EvalTree(Root->Child[0]); 1089 EvalTree(Root->Child[1]); 1088 1090 number = (R2N(Root->Child[0]->Result) > R2N(Root->Child[1]->Result)); 1089 1091 break; … … 1091 1093 case O_GE: /* numeric greater equal */ 1092 1094 type = R_NUMBER; 1093 EvalTree(Root->Child[0]);1094 EvalTree(Root->Child[1]);1095 EvalTree(Root->Child[0]); 1096 EvalTree(Root->Child[1]); 1095 1097 number = (R2N(Root->Child[0]->Result) >= R2N(Root->Child[1]->Result)); 1096 1098 break; … … 1098 1100 case O_ADD: /* addition */ 1099 1101 type = R_NUMBER; 1100 EvalTree(Root->Child[0]);1101 EvalTree(Root->Child[1]);1102 EvalTree(Root->Child[0]); 1103 EvalTree(Root->Child[1]); 1102 1104 number = R2N(Root->Child[0]->Result) + R2N(Root->Child[1]->Result); 1103 1105 break; … … 1105 1107 case O_SUB: /* subtraction */ 1106 1108 type = R_NUMBER; 1107 EvalTree(Root->Child[0]);1108 EvalTree(Root->Child[1]);1109 EvalTree(Root->Child[0]); 1110 EvalTree(Root->Child[1]); 1109 1111 number = R2N(Root->Child[0]->Result) - R2N(Root->Child[1]->Result); 1110 1112 break; … … 1112 1114 case O_SGN: /* sign */ 1113 1115 type = R_NUMBER; 1114 EvalTree(Root->Child[0]);1116 EvalTree(Root->Child[0]); 1115 1117 number = -R2N(Root->Child[0]->Result); 1116 1118 break; … … 1118 1120 case O_CAT: /* string concatenation */ 1119 1121 type = R_STRING; 1120 EvalTree(Root->Child[0]);1121 EvalTree(Root->Child[1]);1122 EvalTree(Root->Child[0]); 1123 EvalTree(Root->Child[1]); 1122 1124 s1 = R2S(Root->Child[0]->Result); 1123 1125 s2 = R2S(Root->Child[1]->Result); … … 1130 1132 case O_MUL: /* multiplication */ 1131 1133 type = R_NUMBER; 1132 EvalTree(Root->Child[0]);1133 EvalTree(Root->Child[1]);1134 EvalTree(Root->Child[0]); 1135 EvalTree(Root->Child[1]); 1134 1136 number = R2N(Root->Child[0]->Result) * R2N(Root->Child[1]->Result); 1135 1137 break; … … 1137 1139 case O_DIV: /* division */ 1138 1140 type = R_NUMBER; 1139 EvalTree(Root->Child[0]);1140 EvalTree(Root->Child[1]);1141 EvalTree(Root->Child[0]); 1142 EvalTree(Root->Child[1]); 1141 1143 dummy = R2N(Root->Child[1]->Result); 1142 1144 if (dummy == 0) { … … 1150 1152 case O_MOD: /* modulo */ 1151 1153 type = R_NUMBER; 1152 EvalTree(Root->Child[0]);1153 EvalTree(Root->Child[1]);1154 EvalTree(Root->Child[0]); 1155 EvalTree(Root->Child[1]); 1154 1156 dummy = R2N(Root->Child[1]->Result); 1155 1157 if (dummy == 0) { … … 1163 1165 case O_POW: /* x^y */ 1164 1166 type = R_NUMBER; 1165 EvalTree(Root->Child[0]);1166 EvalTree(Root->Child[1]);1167 EvalTree(Root->Child[0]); 1168 EvalTree(Root->Child[1]); 1167 1169 number = pow(R2N(Root->Child[0]->Result), R2N(Root->Child[1]->Result)); 1168 1170 break; … … 1170 1172 case O_NOT: /* logical NOT */ 1171 1173 type = R_NUMBER; 1172 EvalTree(Root->Child[0]);1174 EvalTree(Root->Child[0]); 1173 1175 number = (R2N(Root->Child[0]->Result) == 0.0); 1174 1176 break; -
branches/volker_dev/lcd4linux.c
r818 r822 245 245 printf("%s\n", copyright); 246 246 drv_list(); 247 printf("\n");248 plugin_list();247 printf("\n"); 248 plugin_list(); 249 249 exit(0); 250 250 case 'o':
