void lcd_string(uint8_t *string_to_print) { uint32_t count=0; while (string_to_print[count] != 0) { lcd_put (string_to_print[count], TEXT); count++; } }
OCEntityHandlerResult LcdOCEntityHandlerCb(OCEntityHandlerFlag flag, OCEntityHandlerRequest * entityHandlerRequest, void *callbackParam) { OCEntityHandlerResult ehRet = OC_EH_OK; OCEntityHandlerResponse response = {0}; OCRepPayload* payload = OCRepPayloadCreate(); if(!payload) { OC_LOG(ERROR, TAG, ("Failed to allocate Payload")); return OC_EH_ERROR; } if(entityHandlerRequest && (flag & OC_REQUEST_FLAG)) { OC_LOG (INFO, TAG, ("Flag includes OC_REQUEST_FLAG")); if(OC_REST_GET == entityHandlerRequest->method) { OCRepPayloadSetUri(payload, "/grove/lcd"); OCRepPayloadSetPropString(payload, "lcd", (const char *)lcd.str); } else if(OC_REST_PUT == entityHandlerRequest->method) { OC_LOG(INFO, TAG, ("PUT request")); OCRepPayload *rep = (OCRepPayload *)entityHandlerRequest->payload; OCRepPayloadGetPropString(rep, "lcd", &lcd.str); OC_LOG_V(INFO, TAG, "LCD string: %s", lcd.str); lcd_put(); OCRepPayloadSetPropString(payload, "lcd", (const char *)lcd.str); } if (ehRet == OC_EH_OK) { // Format the response. Note this requires some info about the request response.requestHandle = entityHandlerRequest->requestHandle; response.resourceHandle = entityHandlerRequest->resource; response.ehResult = ehRet; response.payload = (OCPayload*) payload; response.numSendVendorSpecificHeaderOptions = 0; memset(response.sendVendorSpecificHeaderOptions, 0, sizeof response.sendVendorSpecificHeaderOptions); memset(response.resourceUri, 0, sizeof response.resourceUri); // Indicate that response is NOT in a persistent buffer response.persistentBufferFlag = 0; // Send the response if (OCDoResponse(&response) != OC_STACK_OK) { OC_LOG(ERROR, TAG, "Error sending response"); ehRet = OC_EH_ERROR; } } } if (entityHandlerRequest && (flag & OC_OBSERVE_FLAG)) { if (OC_OBSERVE_REGISTER == entityHandlerRequest->obsInfo.action) { OC_LOG (INFO, TAG, ("Received OC_OBSERVE_REGISTER from client")); gLightUnderObservation = 1; } else if (OC_OBSERVE_DEREGISTER == entityHandlerRequest->obsInfo.action) { OC_LOG (INFO, TAG, ("Received OC_OBSERVE_DEREGISTER from client")); gLightUnderObservation = 0; } } OCRepPayloadDestroy(payload); return ehRet; }
static void __exit test_cleanup(void) { misc_deregister(&mdev); lcd_put(); dma_free_writecombine(NULL, FB_MEM_SIZE, fb_mem_virt, fb_mem_phys); }
char _key_string(char __mode) { unsigned char __chr = 0, __i = 0; uint8_t __key = 0; if(__mode==0) { CURSOR_SHOW; while(1) { __key = _key_scan(_PAD_SINGLE); if(__key==_KEY_NULL || __key==_KEY_TIKET || __key==_KEY_MENU || __key==_KEY_SHIFT); else if(__key==_KEY_CANCEL) { __chr_count = 0; CURSOR_HIDE; _SHIFT_OFF;// return 1; } else if(__key==_KEY_ENTER) { __chr_count = 0; CURSOR_HIDE; _SHIFT_OFF;// return 0; } else if(__key==_KEY_CLEAR) { if(__chr_count>0) { _LCD_LEFT; _lcd(0x10); _LCD_LEFT; __buf_string[__chr_count-1] = '\0'; __chr_count--; } } else { if(__chr_count<__max_string) { _lcd(_table_alphanum(0, __key, 0)); __buf_string[__chr_count] = _table_alphanum(0, __key, 0); __buf_string[__chr_count + 1] = '\0'; __chr_count++; } } } } if(__mode==_STRING_ALPHANUM) { while(1) { CURSOR_SHOW; __key = _key_scan(_PAD_MULTI); if(__key == _KEY_NULL || __key == _KEY_TIKET || __key == _KEY_MENU); else if(__key == _KEY_CANCEL) { CURSOR_HIDE; _SHIFT_OFF; return 1; } else if(__key == _KEY_ENTER) { CURSOR_HIDE; _SHIFT_OFF; return 0; } else if(__key == _KEY_SHIFT) { __caps_lock = __caps_lock ^ 1; } else if(__key == _KEY_CLEAR) { if(__chr_count > 0) { if(!__key_shift) { _LCD_LEFT; _lcd(0x10); _LCD_LEFT; __buf_string[__chr_count - 1] = '\0'; __chr_count--; if(__chr_count == 19) { lcd_put(2, 20, 0x10); lcd_xy(2, 20); } _SHIFT_OFF; CURSOR_SHOW; //_SHIFT_FREE; } } } else { if(__chr_count < __max_string) { if(__key != __buf_anum) { __buf_anum = __key; __hit_count = 0; if(__key_shift == 1 && __buf_anum != 0) { _LCD_RIGHT; __chr_count++; if(__chr_count == 20) lcd_xy(3, 1); } } else { __hit_count++; } __chr = _table_alphanum(__caps_lock, __key, __hit_count); if(__chr == '\0') { __hit_count = 0; __chr = _table_alphanum(__caps_lock, __key, __hit_count); } if(__chr_count < __max_string) { _lcd(__chr); _LCD_LEFT; __buf_string[__chr_count] = __chr; __buf_string[__chr_count + 1] = '\0'; } } CURSOR_SHOW; //else _SHIFT_LOCK; } } } if(__mode==_STRING_PASSWORD) { CURSOR_SHOW; while(1) { __key = _key_scan(_PAD_SINGLE); if(__key==_KEY_NULL || __key==_KEY_TIKET || __key==_KEY_MENU || __key==_KEY_SHIFT); else if(__key==_KEY_CANCEL) { __chr_count = 0; CURSOR_HIDE; return 1; } else if(__key==_KEY_ENTER) { __chr_count = 0; CURSOR_HIDE; return 0; } else if(__key==_KEY_CLEAR) { if(__chr_count>0) { _LCD_LEFT; _lcd(0x10); _LCD_LEFT; __buf_string[__chr_count-1] = '\0'; __chr_count--; } } else { if(__chr_count<__max_string) { _lcd(0x2a); __buf_string[__chr_count] = _table_alphanum(0, __key, 0); __buf_string[__chr_count + 1] = '\0'; __chr_count++; } } } } if(__mode==_STRING_VALUE) { for(__i=0; __i<__max_string; __i++) _lcd('0'); while(1) { __key = _key_scan(_PAD_SINGLE); if(__key==_KEY_NULL || __key==_KEY_TIKET || __key==_KEY_MENU || __key==_KEY_SHIFT || __key==_KEY_CLEAR); else if(__key==_KEY_CANCEL) { __chr_count = 0; CURSOR_HIDE; return 1; } else if(__key==_KEY_ENTER) { __chr_count = 0; CURSOR_HIDE; return 0; } else { for(__i=0; __i<__max_string - 1; __i++) __buf_string[__i] = __buf_string[__i + 1]; __buf_string[__max_string - 1] = _table_alphanum(0, __key, 0); __buf_string[__max_string] = '\0'; for(__i=0; __i<__max_string; __i++) _LCD_LEFT; for(__i=0; __i<__max_string; __i++) _lcd(__buf_string[__i]); } } } return 0; }
void lcd_command (enum LcdCommand command) { //This function sends a command to the LCD. //Care is taken not to interfere with the other lines on the port. lcd_put((uint8_t)command, COMMAND); delay(3000); // 3 ms (double the delay we should need for any command) }