Created
December 1, 2015 04:40
-
-
Save michaellin/a1aa0e69aa8a7a0b7787 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/***Module for writing to LCD inputs and controlling RGB LED strip from shift register***/ | |
initalize module variables | |
/************************************************************** | |
Function: LCD_HWInit | |
Takes: nothing | |
Returns: nothing | |
Purpose: initializes shift register connected to LCD | |
/*************************************************************/ | |
LCD_HWInit | |
call shift register init function | |
end | |
/************************************************************** | |
Function: LCD_RegisterSelect | |
Takes: 8 bit integer | |
Returns: nothing | |
Purpose: passes input parameter to RegisterSelect variable | |
/*************************************************************/ | |
LCD_RegisterSelect | |
pass input parameter to a static variable | |
end | |
/************************************************************** | |
Function: LCD_SetData4 | |
Takes: 8 bit integer | |
Returns: nothing | |
Purpose: sets 4 bits of data at the input to the LCD | |
/*************************************************************/ | |
LCD_SetData4 | |
get the current value of the port so that we can preserve the other bit states | |
insert the current state of RegisterSelect into bit 6 | |
clear 4 LSB, while preserving 4 MSB | |
OR currentvalue with 4LSB of NewData | |
write data into register | |
end | |
/************************************************************** | |
Function: LCD_PulseEnable | |
Takes: nothing | |
Returns: nothing | |
Purpose: pulses enable clock on LCD | |
/*************************************************************/ | |
LCD_PulseEnable | |
get the current value of the port so that we can preserve the other bit states | |
pulse enable line high | |
pulse enable line low | |
end | |
/************************************************************** | |
Function: LCD_Write4 | |
Takes: 8 bit integer | |
Returns: nothing | |
Purpose: Writes a 4 bit nibble to LCD | |
/*************************************************************/ | |
LCD_Write4 | |
put the 4 bits of data onto the LCD data lines | |
pulse the enable line to complete the write | |
end | |
/************************************************************** | |
Function: LCD_Write8v2 (version 2 of LCD_Write8) | |
Takes: 8 bit integer | |
Returns: nothing | |
Purpose: Writes an 8 bit nibble of data to LCD. | |
/*************************************************************/ | |
LCD_Write8v2 | |
Shift 4MSB into 4LSB positions | |
Write nibble to LCD | |
Mask NewData to get 4LSB | |
Write nibble to LCD | |
end | |
/************************************************************** | |
Function: LCD_WriteCommand4 | |
Takes: 8 bit integer | |
Returns: nothing | |
Purpose: Writes a 4 bit nibble to the LCD in the form of a command. | |
/*************************************************************/ | |
LCD_WriteCommand4 | |
Clear the register select bit | |
Write the 4LSB to the shift register | |
end | |
/************************************************************** | |
Function: LCD_WriteCommand8 | |
Takes: 8 bit integer | |
Returns: nothing | |
Purpose: Writes an 8 bit command to the LCD via two 4 bit nibbles. | |
/*************************************************************/ | |
LCD_WriteCommand8 | |
Clear the register select bit | |
Write 8 bit command to LCD | |
end | |
/************************************************************** | |
Function: LCD_WriteData8 | |
Takes: 8 bit integer | |
Returns: nothing | |
Purpose: Writes 8 bits of data to the LCD via two 4 bit nibbles. | |
/*************************************************************/ | |
LCD_WriteData8 | |
Set the register select bit high | |
Write 8 bits of data to the shift register via two 4 bit nibbles | |
end | |
/******** THE FOLLOWING FUNCTIONS SUPPORT THE RGB LED STRIP USED IN CELEBRATION MODE********/ | |
/************************************************************** | |
Function: LCD_RedLEDOn | |
Takes: nothing | |
Returns: nothing | |
Purpose: Turn on red LEDs on RGB LED strip. | |
/*************************************************************/ | |
LCD_RedLEDOn | |
Initialize CurrentValue variable | |
Get current image of shift register data lines | |
Set bit 4 high on shift register without altering LCD inputs | |
Write this to shift register outputs | |
end | |
/************************************************************** | |
Function: LCD_RedLEDOff | |
Takes: nothing | |
Returns: nothing | |
Purpose: Turn off red LEDs on RGB LED strip. | |
/*************************************************************/ | |
LCD_RedLEDOff | |
Initialize CurrentValue variable | |
Get current image of shift register data lines | |
Set bit 4 low on shift register without altering LCD inputs | |
Write this to shift register outputs | |
end | |
/************************************************************** | |
Function: LCD_BlueLEDOn | |
Takes: nothing | |
Returns: nothing | |
Purpose: Turn on blue LEDs on RGB LED strip. | |
/*************************************************************/ | |
LCD_BlueLEDOn | |
Initialize CurrentValue variable | |
Get current image of shift register data lines | |
Set bit 5 high on shift register without altering LCD inputs | |
Write this to shift register outputs | |
end | |
/************************************************************** | |
Function: LCD_BlueLEDOff | |
Takes: nothing | |
Returns: nothing | |
Purpose: Turn off blue LEDs on RGB LED strip. | |
/*************************************************************/ | |
LCD_BlueLEDOff | |
Initialize CurrentValue variable | |
Get current image of shift register data lines | |
Set bit 5 low on shift register without altering LCD inputs | |
Write this to shift register outputs | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment