├── LICENSE ├── README.md └── futaba_8md06inkm.py /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Reboot93 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Futaba VFD display (8-MD-06INKM) driver for MicroPython (Framebuf) 2 | 3 | [![Sample video](https://res.cloudinary.com/marcomontalbano/image/upload/v1659263094/video_to_markdown/images/youtube--nW1mT3Vwk4U-c05b58ac6eb4c4700831b2b3070cd403.jpg)](https://www.youtube.com/watch?v=nW1mT3Vwk4U "Sample video") 4 | 5 | ## Usage sample 6 | **使用示例:** 7 | ``` python 8 | import framebuf, futaba_8md06inkm, time 9 | from machine import Pin, freq, SPI 10 | 11 | freq(240000000) 12 | 13 | hspi = SPI(1, 5000000) 14 | en = Pin(4) 15 | rst = Pin(5) 16 | cs = Pin(26) 17 | display = Futaba_8MD06INKM.VFD(hspi, rst, cs, en) 18 | ``` 19 | ### Framebuf base display 20 | 基于Framebuf显示 21 | ``` python 22 | display.fill(0) 23 | display.text('Reboot93', i, 0) 24 | display.show() 25 | ``` 26 | 27 | ### Display built-in charaters (Similar ssd1306) 28 | 显示内置字符 (类似ssd1306) 29 | ``` python 30 | display.display_str(0, ‘12345678’) # Starting at block 0 display '12345678' 31 | # 从0位开始显示'12345678' 32 | # Only characters that already exist in the CGRAM can be display 33 | # 只能显示CGRAM中已经存在的字符 34 | ``` 35 | ### Customize the display content in a single block 36 | 自定义单块显示内容 37 | ``` python 38 | buf = bytearray(5) 39 | fbuf = framebuf.FrameBuffer(buf, 5, 7, framebuf.MONO_VLSB) 40 | fbuf.rect(0, 0, 5, 7, 1) 41 | display.display_custom(0,buf) 42 | ``` 43 | ### Clear the display 44 | 清除显示内容 45 | ``` python 46 | display.clear() # 清除所有 clear all 47 | display.clear(0) # 清除0位 clear block 0 48 | ``` 49 | ### Set the luminance 50 | 设置亮度 51 | ``` python 52 | display.set_display_dimming(255) # 0~255 53 | ``` 54 | ### Turn the display on or off(Stand-by mode) 55 | 开/关屏幕 56 | ``` python 57 | display.on() 58 | display.off() 59 | ``` 60 | -------------------------------------------------------------------------------- /futaba_8md06inkm.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 8MD-06INKM Futaba VFD display driver for MicroPython 3 | 4 | ==================================================== 5 | MIT License 6 | 7 | Copyright (c) 2020 Reboot93 8 | 9 | Permission is hereby granted, free of charge, to any person obtaining a copy 10 | of this software and associated documentation files (the "Software"), to deal 11 | in the Software without restriction, including without limitation the rights 12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | copies of the Software, and to permit persons to whom the Software is 14 | furnished to do so, subject to the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be included in all 17 | copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | SOFTWARE. 26 | ''' 27 | 28 | import framebuf 29 | from micropython import const 30 | 31 | DCRAM_DATA_WRITE = const(0x20) 32 | DGRAM_DATA_CLAER = const(0x10) 33 | CGRAM_DATA_WRITE = const(0x40) 34 | SET_DISPLAY_TIMING = const(0xE0) 35 | SET_DIMMING_DATA = const(0xE4) 36 | SET_DISPLAT_LIGHT_ON = const(0xE8) 37 | SET_DISPLAT_LIGHT_OFF = const(0xEA) 38 | SET_STAND_BY_MODE = const(0xEC) 39 | 40 | 41 | class VFD(framebuf.FrameBuffer): 42 | 43 | def __init__(self, spi, res, cs, en, digits=8, dimming=255): 44 | self.rate = 5000000 45 | self.digits = digits 46 | self.dimming = dimming 47 | res.init(res.OUT, value=0) 48 | cs.init(cs.OUT, value=1) 49 | en.init(en.OUT, value=1) 50 | 51 | self.spi = spi 52 | self.res = res 53 | self.cs = cs 54 | self.buffer = bytearray(5 * self.digits) 55 | super().__init__(self.buffer, 5 * self.digits, 7, framebuf.MONO_VLSB) 56 | import time 57 | 58 | # init VFD display 59 | self.res(1) 60 | time.sleep_ms(1) 61 | self.res(0) 62 | time.sleep_ms(10) 63 | self.res(1) 64 | time.sleep_ms(3) 65 | self.init_display() 66 | 67 | def init_display(self): 68 | for cmd in ( 69 | # Set Display timing 70 | (SET_DISPLAY_TIMING, self.digits - 1), 71 | # Set the URAM (when digits > 16) 72 | # Set Display Dimming data 73 | (SET_DIMMING_DATA, self.dimming), 74 | # Release the All display OFF 75 | (SET_DISPLAT_LIGHT_ON, 0x00) 76 | ): 77 | self.__write_cmd(cmd) 78 | 79 | def display_claer(self, *address: int): 80 | if address: 81 | self.__write_cmd((DCRAM_DATA_WRITE | address, DGRAM_DATA_CLAER)) 82 | else: 83 | for i in range(self.digits): 84 | self.__write_cmd((DCRAM_DATA_WRITE | i, DGRAM_DATA_CLAER)) 85 | 86 | def display_str(self, address: int, msg: str): 87 | for i in msg: 88 | self.__write_cmd((DCRAM_DATA_WRITE | address, ord(i))) 89 | if address < self.digits - 1: 90 | address += 1 91 | else: 92 | break 93 | 94 | def display_custom(self, address: int, buf: bytearray): 95 | self.__write_data(address, buf) 96 | self.__write_cmd((DCRAM_DATA_WRITE | address, address)) 97 | 98 | def show(self): 99 | buf = bytearray(5) 100 | fbuf = framebuf.FrameBuffer(buf, 5, 7, framebuf.MONO_VLSB) 101 | for i in range(self.digits): 102 | fbuf.fill(0) 103 | fbuf.blit(self, 0 - (i * 5), 0) 104 | self.__write_data(i, buf) 105 | for i in range(self.digits): 106 | self.__write_cmd((DCRAM_DATA_WRITE | i, i)) 107 | 108 | def set_display_dimming(self, dimming: int): 109 | dimming_data = dimming 110 | self.__write_cmd((SET_DIMMING_DATA, dimming_data)) 111 | 112 | def on(self): 113 | self.__write_cmd([SET_STAND_BY_MODE, 0x00]) 114 | 115 | def off(self): 116 | self.__write_cmd([SET_STAND_BY_MODE | 1, 0x00]) 117 | 118 | def __write_cmd(self, cmd): 119 | self.spi.init(baudrate=self.rate, polarity=0, phase=0, firstbit=self.spi.LSB) 120 | self.cs(1) 121 | self.cs(0) 122 | for i in cmd: 123 | self.spi.write(bytearray([i])) 124 | self.cs(1) 125 | 126 | def __write_data(self, address: int, buf): 127 | self.spi.init(baudrate=self.rate, polarity=0, phase=0, firstbit=self.spi.LSB) 128 | self.cs(1) 129 | self.cs(0) 130 | self.spi.write(bytearray([CGRAM_DATA_WRITE | address])) 131 | for i in buf: 132 | self.spi.write(bytearray([i])) 133 | self.cs(1) 134 | --------------------------------------------------------------------------------