Download Capacitive-Touch Color Wheel Implementation
Transcript
AP08113 Capacitive-Touch Color Wheel Implementation Implementation of Color Wheel Software 3.4 Overview Flow Chart of Color Wheel Software Code Figure 4 shows the overview flow chart of the Color Wheel software code. Start Initialization of all modules (Handled by XC800_FLOAD.exe, by clicking “Connect” button) Check for P2.0=1 and P2.1=0 Enter UART BSL Mode to update software code y n Light up “ON” LED Call “Touch-Wheel Library” Function to: - detect if touch-wheel is touched - calculate AverageL/H - calculate Angle n Touch-wheel is touched? Centre button is touched? n y y Update Wheel_hue/sat/lum with Angle (output from TouchWheel Lib), depending on which color mode is enabled. Change colur mode and respective LED3/2/1 (loop) Centre button is touched for long period? y n Light up RGB LED (D2) -Transform HSL to RGB -Update PWM duty cycle according to RGB value n Enter Power Down Mode - Disable interrupts - Disable WDT, if enabled - Disable all peripherals and ports except TS - Configure RTC for 1 second - Save SFR LTS_TSVAL value - Enter Power Down Mode 2 - Upon wake up, wait for Time Frame interrupt, then compare current LTS_TSVAL with the saved_value (saved value of LTS_TSVAL – TSVAL_SUBTRACTION) LTS_TSVAL > saved_value? y Figure 4 Overview Flow Chart of the Color Wheel Software Code Application Note 11 V1.0, 2010-08