mirror of
https://github.com/espruino/Espruino.git
synced 2026-02-01 15:55:37 +00:00
Pixl.js: Add Pixl.setLCDPower to allow the LCD to be powered off, more than halving power consumption
This commit is contained in:
parent
603add02f9
commit
87f2ce3e03
@ -68,6 +68,7 @@
|
||||
Automatically shut down UART if both pin states are changed
|
||||
Fix `setDeviceClockCmd: Unknown Device` when using `LoopbackB.setConsole()` on WiFi board
|
||||
Fix non-UART serial regressions (after software serial additions)
|
||||
Pixl.js: Add Pixl.setLCDPower to allow the LCD to be powered off, more than halving power consumption
|
||||
|
||||
1v99 : Increase jslMatch error buffer size to handle "UNFINISHED TEMPLATE LITERAL" string (#1426)
|
||||
nRF5x: Make FlashWrite cope with flash writes > 4k
|
||||
|
||||
@ -293,6 +293,33 @@ void jswrap_pixljs_setContrast(JsVarFloat c) {
|
||||
jshPinSetValue(LCD_SPI_CS,1);
|
||||
}
|
||||
|
||||
/*JSON{
|
||||
"type" : "staticmethod",
|
||||
"class" : "Pixl",
|
||||
"name" : "setLCDPower",
|
||||
"generate" : "jswrap_pixljs_setLCDPower",
|
||||
"params" : [
|
||||
["isOn","bool","True if the LCD should be on, false if not"]
|
||||
]
|
||||
}
|
||||
This function can be used to turn Pixl.js's LCD off or on.
|
||||
|
||||
* With the LCD off, Pixl.js draws around 0.1mA
|
||||
* With the LCD on, Pixl.js draws around 0.25mA
|
||||
*/
|
||||
void jswrap_pixljs_setLCDPower(bool isOn) {
|
||||
jshPinSetValue(LCD_SPI_CS,0);
|
||||
jshPinSetValue(LCD_SPI_DC,0);
|
||||
if (isOn) {
|
||||
lcd_wr(0xA4); // cancel pixel on
|
||||
lcd_wr(0xAF); // display on
|
||||
} else {
|
||||
lcd_wr(0xAE); // display off
|
||||
lcd_wr(0xA5); // all pixels on
|
||||
}
|
||||
jshPinSetValue(LCD_SPI_CS,1);
|
||||
}
|
||||
|
||||
/*JSON{
|
||||
"type" : "staticmethod",
|
||||
"class" : "Pixl",
|
||||
@ -471,7 +498,8 @@ void jswrap_pixljs_init() {
|
||||
};
|
||||
|
||||
// Create 'flip' fn
|
||||
JsVar *fn = jsvNewNativeFunction((void (*)(void))lcd_flip, JSWAT_VOID|JSWAT_THIS_ARG|(JSWAT_BOOL << (JSWAT_BITS*1)));
|
||||
JsVar *fn;
|
||||
fn = jsvNewNativeFunction((void (*)(void))lcd_flip, JSWAT_VOID|JSWAT_THIS_ARG|(JSWAT_BOOL << (JSWAT_BITS*1)));
|
||||
jsvObjectSetChildAndUnLock(graphics,"flip",fn);
|
||||
// LCD init 2
|
||||
jshDelayMicroseconds(10000);
|
||||
@ -486,6 +514,7 @@ void jswrap_pixljs_init() {
|
||||
35, // actual contrast (0..63)
|
||||
0x25, // regulation resistor ratio (0..7)
|
||||
0x2F, // control power circuits - last 3 bits = VB/VR/VF
|
||||
0xF8, 1, // Set boost level to 5x - draws maybe 0.04mA more, but much better blacks
|
||||
0xA0, // start at column 128
|
||||
0xAF // disp on
|
||||
};
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
JsVar *jswrap_pixljs_menu(JsVar *menu);
|
||||
void jswrap_pixljs_lcdw(JsVarInt c);
|
||||
void jswrap_pixljs_setContrast(JsVarFloat c);
|
||||
void jswrap_pixljs_setLCDPower(bool isOn);
|
||||
|
||||
void jswrap_pixljs_init();
|
||||
void jswrap_pixljs_kill();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user