Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: N5110/N5110.h
- Revision:
- 24:67dc71a8f009
- Parent:
- 23:9be87557b89a
diff -r 9be87557b89a -r 67dc71a8f009 N5110/N5110.h
--- a/N5110/N5110.h Wed May 08 08:46:11 2019 +0000
+++ b/N5110/N5110.h Wed May 08 14:24:53 2019 +0000
@@ -3,30 +3,6 @@
#include "mbed.h"
-// Command Bytes - taken from Chris Yan's library
-// More information can be found in the display datasheet
-// H = 0 - Basic instructions
-#define CMD_DC_CLEAR_DISPLAY 0x08
-#define CMD_DC_NORMAL_MODE 0x0C
-#define CMD_DC_FILL_DISPLAY 0x09
-#define CMD_DC_INVERT_VIDEO 0x0D
-#define CMD_FS_HORIZONTAL_MODE 0x00
-#define CMD_FS_VERTICAL_MODE 0x02
-#define CMD_FS_BASIC_MODE 0x00
-#define CMD_FS_EXTENDED_MODE 0x01
-#define CMD_FS_ACTIVE_MODE 0x00
-#define CMD_FS_POWER_DOWN_MODE 0x04
-// H = 1 - Extended instructions
-#define CMD_TC_TEMP_0 0x04
-#define CMD_TC_TEMP_1 0x05
-#define CMD_TC_TEMP_2 0x06
-#define CMD_TC_TEMP_3 0x07
-#define CMD_BI_MUX_24 0x15
-#define CMD_BI_MUX_48 0x13
-#define CMD_BI_MUX_100 0x10
-#define CMD_VOP_6V06 0xB2
-#define CMD_VOP_7V38 0xC8
-
// number of pixels on display
#define WIDTH 84
#define HEIGHT 48
@@ -78,6 +54,10 @@
{
// first need to initialise display
lcd.init();
+
+ // change set contrast in range 0.0 to 1.0
+ // 0.4 appears to be a good starting point
+ lcd.setContrast(0.4);
while(1) {
@@ -86,7 +66,7 @@
lcd.setBrightness(0.5); // put LED backlight on 50%
lcd.clear();
- // x origin, y origin, rows, cols, sprite
+ // x origin, y origin, rows, cols, sprite
lcd.drawSprite(20,6,8,5,(int *)sprite);
lcd.refresh();
wait(5.0);
@@ -114,23 +94,15 @@
// draw a line across the display at y = 40 pixels (origin top-left)
for (int i = 0; i < WIDTH; i++) {
- lcd.setPixel(i,40);
+ lcd.setPixel(i,40,true);
}
// need to refresh display after setting pixels or writing strings
lcd.refresh();
wait(5.0);
- for(int i = 0; i < 3; i++) {
- for(int j = 0; j < 5; j++) {
- printf("%d,%d = %d\n",i,j,glyph[i][j]);
- }
- }
-
-
-
// can check status of pixel using getPixel(x,y);
lcd.clear(); // clear buffer
- lcd.setPixel(2,2); // set random pixel in buffer
+ lcd.setPixel(2,2,true); // set random pixel in buffer
lcd.refresh();
wait(1.0);
@@ -141,6 +113,8 @@
}
// this one shouldn't be set
+ lcd.setPixel(3,3,false); // clear random pixel in buffer
+ lcd.refresh();
pixel_to_test = lcd.getPixel(3,3);
if ( pixel_to_test == 0 ) {
@@ -278,6 +252,11 @@
*/
void clear();
+ /** Set screen constrast
+ * @param constrast - float in range 0.0 to 1.0 (0.40 to 0.60 is usually a good value)
+ */
+ void setContrast(float contrast);
+
/** Turn on normal video mode (default)
* Black on white
*/
@@ -316,23 +295,33 @@
unsigned int const x,
unsigned int const y);
- /** Set a Pixel
+ /**
+ * @brief Set a Pixel
*
- * This function sets a pixel in the screen buffer.
- * @param x - the x co-ordinate of the pixel (0 to 83)
- * @param y - the y co-ordinate of the pixel (0 to 47)
+ * @param x The x co-ordinate of the pixel (0 to 83)
+ * @param y The y co-ordinate of the pixel (0 to 47)
+ * @param state The state of the pixel [true=black (default), false=white]
+ *
+ * @details This function sets the state of a pixel in the screen buffer.
+ * The third parameter can be omitted,
*/
void setPixel(unsigned int const x,
- unsigned int const y);
+ unsigned int const y,
+ bool const state = true);
- /** Clear a Pixel
+ /**
+ * @brief Clear a Pixel
*
- * This function clears pixel in the screen buffer
* @param x - the x co-ordinate of the pixel (0 to 83)
* @param y - the y co-ordinate of the pixel (0 to 47)
+ *
+ * @details This function clears pixel in the screen buffer
+ *
+ * @deprecated Use setPixel(x, y, false) instead
*/
void clearPixel(unsigned int const x,
- unsigned int const y);
+ unsigned int const y)
+ __attribute__((deprecated("Use setPixel(x,y,false) instead")));
/** Get a Pixel
*
@@ -427,7 +416,8 @@
int nrows,
int ncols,
int *sprite);
-
+
+
private:
// methods
void setXYAddress(unsigned int const x,
@@ -438,6 +428,8 @@
void clearRAM();
void sendCommand(unsigned char command);
void sendData(unsigned char data);
+ void setTempCoefficient(char tc); // 0 to 3
+ void setBias(char bias); // 0 to 7
};
const unsigned char font5x7[480] = {