Mercurial > louis > kiibohd-controller
comparison Scan/STLcd/lcd_scan.c @ 366:95ae53b1e088
Adding basic support for LCDLayerDisplay using capabilities
- Requires lcdFuncMap.kll instead of stdFuncMap.kll
author | Jacob Alexander <haata@kiibohd.com> |
---|---|
date | Tue, 18 Aug 2015 01:10:44 -0700 |
parents | 86b937945313 |
children | 8a6c2d410ad9 |
comparison
equal
deleted
inserted
replaced
365:dbe0dbd7e2dd | 366:95ae53b1e088 |
---|---|
340 return 0; | 340 return 0; |
341 } | 341 } |
342 | 342 |
343 | 343 |
344 | 344 |
345 // ----- Capabilities ----- | |
346 | |
347 uint16_t LCD_layerStack_prevSize = 0; | |
348 void LCD_layerStack_capability( uint8_t state, uint8_t stateType, uint8_t *args ) | |
349 { | |
350 // Display capability name | |
351 if ( stateType == 0xFF && state == 0xFF ) | |
352 { | |
353 print("LCD_layerStack_capability"); | |
354 return; | |
355 } | |
356 | |
357 // Parse the layer stack, top to bottom | |
358 extern uint16_t macroLayerIndexStack[]; | |
359 extern uint16_t macroLayerIndexStackSize; | |
360 | |
361 // Only process if the stack size has changed | |
362 if ( macroLayerIndexStackSize == LCD_layerStack_prevSize ) | |
363 { | |
364 return; | |
365 } | |
366 LCD_layerStack_prevSize = macroLayerIndexStackSize; | |
367 | |
368 // Number data for LCD | |
369 const uint8_t numbers[10][128] = { | |
370 { STLcdNumber0_define }, | |
371 { STLcdNumber1_define }, | |
372 { STLcdNumber2_define }, | |
373 { STLcdNumber3_define }, | |
374 { STLcdNumber4_define }, | |
375 { STLcdNumber5_define }, | |
376 { STLcdNumber6_define }, | |
377 { STLcdNumber7_define }, | |
378 { STLcdNumber8_define }, | |
379 { STLcdNumber9_define }, | |
380 }; | |
381 | |
382 // Only display if there are layers active | |
383 if ( macroLayerIndexStackSize > 0 ) | |
384 { | |
385 | |
386 // Iterate through each of the pages | |
387 // XXX Many of the values here are hard-coded | |
388 // Eventually a proper font rendering engine should take care of things like this... -HaaTa | |
389 for ( uint8_t page = 0; page < LCD_TOTAL_VISIBLE_PAGES; page++ ) | |
390 { | |
391 // Set the register page | |
392 LCD_writeControlReg( 0xB0 | ( 0x0F & page ) ); | |
393 | |
394 // Set starting address | |
395 LCD_writeControlReg( 0x10 ); | |
396 LCD_writeControlReg( 0x00 ); | |
397 | |
398 // Write data | |
399 for ( uint16_t layer = 1; layer <= macroLayerIndexStackSize; layer++ ) | |
400 { | |
401 uint16_t layerIndex = macroLayerIndexStack[ macroLayerIndexStackSize - layer ]; | |
402 | |
403 // Default to 0, if over 9 | |
404 if ( layerIndex > 9 ) | |
405 { | |
406 layerIndex = 0; | |
407 } | |
408 | |
409 // Write page of number to display | |
410 SPI_write( (uint8_t*)&numbers[ layerIndex ][ page * 32 ], 32 ); | |
411 } | |
412 | |
413 // Blank out rest of display | |
414 uint8_t data = 0; | |
415 for ( uint8_t c = 0; c < 4 - macroLayerIndexStackSize; c++ ) | |
416 { | |
417 for ( uint8_t byte = 0; byte < 32; byte++ ) | |
418 { | |
419 SPI_write( &data, 1 ); | |
420 } | |
421 } | |
422 } | |
423 } | |
424 else | |
425 { | |
426 // Write default image | |
427 for ( uint8_t page = 0; page < LCD_TOTAL_VISIBLE_PAGES; page++ ) | |
428 LCD_writeDisplayReg( page, (uint8_t *)&STLcdDefaultImage[page * LCD_PAGE_LEN], LCD_PAGE_LEN ); | |
429 } | |
430 } | |
431 | |
432 | |
433 | |
345 // ----- CLI Command Functions ----- | 434 // ----- CLI Command Functions ----- |
346 | 435 |
347 void cliFunc_lcdInit( char* args ) | 436 void cliFunc_lcdInit( char* args ) |
348 { | 437 { |
349 LCD_initialize(); | 438 LCD_initialize(); |