Module: Epaper
- Defined in:
- lib/epaper.rb,
lib/epaper/version.rb,
ext/epaper/epaper.c
Defined Under Namespace
Classes: Error
Constant Summary collapse
- VERSION =
"0.1.3"
Class Method Summary collapse
Class Method Details
.display_image(file_name:) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/epaper.rb', line 12 def display_image(file_name:) Epaper.init image = Magick::ImageList.new(file_name) image.flop! image.scale!(800, 480) image.rotate!(180) # check and convert if not bmp blob = image.to_blob.each_byte.map { |byte| byte ^ 255 }.pack('C*') start = blob.length - 48_000 Epaper.render_image(blob[start..]) end |
.exit ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'ext/epaper/epaper.c', line 34
VALUE rb_epd_exit() {
printf("Clear...\r\n");
EPD_7IN5_V2_Clear();
printf("Goto Sleep...\r\n");
EPD_7IN5_V2_Sleep();
DEV_Delay_ms(2000);//important, at least 2s
DEV_Module_Exit();
return Qnil;
}
|
.init ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'ext/epaper/epaper.c', line 17
VALUE rb_epd_init() {
signal(SIGINT, Handler);
printf("EPD_7IN5_V2_test Demo\r\n");
if(DEV_Module_Init()!=0){
return -1;
}
printf("e-Paper Init and Clear...\r\n");
EPD_7IN5_V2_Init();
EPD_7IN5_V2_Clear();
DEV_Delay_ms(500);
return Qnil;
}
|
.render_image(img) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'ext/epaper/epaper.c', line 48
VALUE rb_epd_render_image(VALUE self, VALUE img)
{
//Create a new image cache
UBYTE *BlackImage;
/* you have to edit the startup_stm32fxxx.s file and set a big enough heap size */
UWORD Imagesize = ((EPD_7IN5_V2_WIDTH % 8 == 0)? (EPD_7IN5_V2_WIDTH / 8 ): (EPD_7IN5_V2_WIDTH / 8 + 1)) * EPD_7IN5_V2_HEIGHT;
if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
printf("Failed to apply for black memory...\r\n");
return -1;
}
printf("Paint_NewImage\r\n");
Paint_NewImage(BlackImage, EPD_7IN5_V2_WIDTH, EPD_7IN5_V2_HEIGHT, 0, WHITE);
printf("show image for array\r\n");
Paint_SelectImage(BlackImage);
Paint_Clear(WHITE);
Paint_DrawBitMap(StringValuePtr(img));
EPD_7IN5_V2_Display(BlackImage);
DEV_Delay_ms(2000);
free(BlackImage);
BlackImage = NULL;
}
|