A basic library for the Freetronics arduino LCD shield.
Fork of freetronicsLCDShield by
Diff: freetronicsLCDShield.h
- Revision:
- 7:56d8df0eb209
- Parent:
- 6:ac481535732f
diff -r ac481535732f -r 56d8df0eb209 freetronicsLCDShield.h --- a/freetronicsLCDShield.h Sun Jul 02 15:05:19 2017 +0000 +++ b/freetronicsLCDShield.h Sun Jul 02 15:26:57 2017 +0000 @@ -1,5 +1,7 @@ /* mbed freetronicsLCDShield Library, written by Koen J.F. Kempeneers * kkempeneers@skynet.be + * Improved button support added by John Bailey + * jdb__mbed(at)anotherdimension.net * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -26,9 +28,9 @@ #define LEFT 0 #define RIGHT 1 +/** Number of detectable buttons on the shield, Left, Right, Up, Down, plus one for "No button" */ #define FREETRONICSLCDSHIELD_BUTTON_COUNT 5 - /** * Provides full LCD support for the HD44780 compatible LCD on the arduino shaped shield. * http://www.freetronics.com/products/lcd-keypad-shield#.UnIr6_nkq0M @@ -170,10 +172,22 @@ /** Reads the status of the buttons * - * + * This function returns the ADC value of the input connected to the buttons. When no button is pressed, this input is pulled high. + * If any button is pressed, the input is connected to ground via a resistor & the function will return a value less than 1.0, + * depending on the button. Approximate values (sourced from the schematic) are: + * Left: 2.47V -> ADC 0.748 + * Down: 1.61V -> ADC 0.488 + * Up: 0.71V -> ADC 0.215 + * Right: 0.00V -> ADC 0.000 + * Note that as ADC inputs are referenced to 3.3V, the select button cannot be read (as the voltage when this buttong is pressed is 3.62V, + * saturating the input and indistinguishable from no button being pressed. */ float readButton(void); + /** Determines which of the buttons is currently pressed + * + * Note that the shield design means that multi-button detection is not practical + */ ShieldButton pressedButton(void); protected: @@ -181,6 +195,7 @@ virtual int _putc(int value); virtual int _getc(); + /** Lower thresholds for the ADC value for each push button on the shield */ static const float buttonThresholds[FREETRONICSLCDSHIELD_BUTTON_COUNT]; };