Created
February 14, 2020 21:27
-
-
Save iainnash/ba462d5b3bca730122d59965b9cb7591 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
let Max2719SPI = { | |
_create: ffi("void *mgos_max7219_create(void *, int)"), | |
_set_devices: ffi("bool mgos_max7219_set_num_devices(void *, int)"), | |
_set_mode: ffi("bool mgos_max7219_set_mode(void *, bool)"), | |
_write_digit: ffi("bool mgos_max7219_write_digit(void *, int, int, int)"), | |
create: function(spi) { | |
let obj = Object.create(Max2719SPI._proto); | |
obj.driver = Max2719SPI._create(spi.spi); | |
return driver; | |
}, | |
_proto: { | |
setDevices: function(number) { | |
return Max2719SPI._set_devices(this.driver, number); | |
}, | |
setMode: function(isRaw) { | |
return Max2719SPI._set_mode(this.driver, !isRaw); | |
}, | |
writeDigit: function(digit, value, device) { | |
if (!device) { | |
device = 0; | |
} | |
return Max2719SPI._write_digit(this.driver, device, digit, value); | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment