C++ file for display control
Dependencies: 4DGL mbed ConfigFile
Fork of 4DGLtest by
keyboard.cpp
- Committer:
- WillemBraat
- Date:
- 2014-06-26
- Revision:
- 3:f7bce78b04c1
- Child:
- 6:904d00252480
File content as of revision 3:f7bce78b04c1:
/* Keyboard chip TCA8418 control */ #include "mbed.h" #include "keyboard.h" extern int key_hit_ID; //extern mbos CDU_OS; //CDU Keyboard communications KEYBOARD_INT InterruptIn CDU_KB_INT( p5 ); //Set CDU keyboard interrupt line. I2C CDU_KB(p28, p27); //Communication lines to keyboard chip //CDU Keyboard LEDS DigitalOut EXEC( p12 ); DigitalOut FAIL( p17 ); DigitalOut DSPY( p18 ); DigitalOut MSG( p19 ); DigitalOut OFST( p20 ); //CDU background lighting AnalogIn BGL_POT( p15 ); //background light control potmeter PwmOut BGL_LED( p21 ); //PWM output /*void CDU_KB_INT_ON() { } */ void CDU_KB_COMM_INIT() { //initialize communication with TCA84818 CDU_KB.write(CDU_KB_WRITE); //initiate write cycle //intialize all registers from TCA8418 here CDU_KB.read(CDU_KB_READ); //start reading from TCA4818 } void CDU_KB_GET_KEY_TASK() { CDU_KB.write(CDU_KB_READ); //initiate read cycle key_hit_ID = CDU_KB.read(CDU_KB_READ) ; //read key value //CDU_OS.SetEvent(KEY_EVENT,SEND_KEYMESSAGE_TASK_ID ); //Set event key to wakeup task } void CDU_KB_INT_START() { CDU_KB_INT.mode( PullUp ); CDU_KB_INT.fall(&CDU_KB_GET_KEY_TASK); } void SET_BGL_INTENSITY( int nVal ) { //AnalogIn BGL_POT( p15 ); //background light control potmeter. Returns a value between 0.0 and 1.0 //PwmOut BGL_LED( p21 ); //PWM output //calculate required brightness in percentage from 0%-100% //nVal 255 --> calculate brightness from potmeter value //nVal = 0 --> switch off backlight //nVal = 100 --> switch on backlight max switch (nVal) { case 0: { //switch off backlighting BGL_LED.pulsewidth( 0.0 ); break; } case 100: { //switch on backlighting BGL_LED.pulsewidth( 100.0 ); break; } case 255: { //calculate percentage from potmeter value BGL_LED.pulsewidth( 0.0 + 100*BGL_POT ); } } }