├── .gitignore
├── LICENSE
├── NBX_OLED
├── OLED.py
└── __init__.py
├── Nabaixin_TFOLED.egg-info
├── PKG-INFO
├── SOURCES.txt
├── dependency_links.txt
├── requires.txt
└── top_level.txt
├── README.md
├── Readme_img
└── readme img.txt
├── TFOL.py
├── build
└── lib
│ └── NBX_OLED
│ ├── OLED.py
│ └── __init__.py
├── dist
└── Nabaixin_TFOLED-1.0.2-py3-none-any.whl
├── image-VWM8FnE.png
├── image-ZyiqR6s.png
├── setup.py
└── tool
├── SSH
└── wpa_supplicant.conf
/.gitignore:
--------------------------------------------------------------------------------
1 | #HTML needed
2 | /Readme_img/
3 |
4 | # Byte-compiled / optimized / DLL files
5 | __pycache__/
6 | *.py[cod]
7 | *$py.class
8 |
9 | # C extensions
10 | *.so
11 |
12 | # Distribution / packaging
13 | .Python
14 | build/
15 | develop-eggs/
16 | dist/
17 | downloads/
18 | eggs/
19 | .eggs/
20 | lib/
21 | lib64/
22 | parts/
23 | sdist/
24 | var/
25 | wheels/
26 | pip-wheel-metadata/
27 | share/python-wheels/
28 | *.egg-info/
29 | .installed.cfg
30 | *.egg
31 | MANIFEST
32 |
33 | # PyInstaller
34 | # Usually these files are written by a python script from a template
35 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
36 | *.manifest
37 | *.spec
38 |
39 | # Installer logs
40 | pip-log.txt
41 | pip-delete-this-directory.txt
42 |
43 | # Unit test / coverage reports
44 | htmlcov/
45 | .tox/
46 | .nox/
47 | .coverage
48 | .coverage.*
49 | .cache
50 | nosetests.xml
51 | coverage.xml
52 | *.cover
53 | *.py,cover
54 | .hypothesis/
55 | .pytest_cache/
56 |
57 | # Translations
58 | *.mo
59 | *.pot
60 |
61 | # Django stuff:
62 | *.log
63 | local_settings.py
64 | db.sqlite3
65 | db.sqlite3-journal
66 |
67 | # Flask stuff:
68 | instance/
69 | .webassets-cache
70 |
71 | # Scrapy stuff:
72 | .scrapy
73 |
74 | # Sphinx documentation
75 | docs/_build/
76 |
77 | # PyBuilder
78 | target/
79 |
80 | # Jupyter Notebook
81 | .ipynb_checkpoints
82 |
83 | # IPython
84 | profile_default/
85 | ipython_config.py
86 |
87 | # pyenv
88 | .python-version
89 |
90 | # pipenv
91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies
93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not
94 | # install all needed dependencies.
95 | #Pipfile.lock
96 |
97 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow
98 | __pypackages__/
99 |
100 | # Celery stuff
101 | celerybeat-schedule
102 | celerybeat.pid
103 |
104 | # SageMath parsed files
105 | *.sage.py
106 |
107 | # Environments
108 | .env
109 | .venv
110 | env/
111 | venv/
112 | ENV/
113 | env.bak/
114 | venv.bak/
115 |
116 | # Spyder project settings
117 | .spyderproject
118 | .spyproject
119 |
120 | # Rope project settings
121 | .ropeproject
122 |
123 | # mkdocs documentation
124 | /site
125 |
126 | # mypy
127 | .mypy_cache/
128 | .dmypy.json
129 | dmypy.json
130 |
131 | # Pyre type checker
132 | .pyre/
133 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Nabaixin
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 |
--------------------------------------------------------------------------------
/NBX_OLED/OLED.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2020
2 | # Author: FrankVon
3 | #
4 | # Permission is hereby granted, free of charge, to any person obtaining a copy
5 | # of this software and associated documentation files (the "Software"), to deal
6 | # in the Software without restriction, including without limitation the rights
7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | # copies of the Software, and to permit persons to whom the Software is
9 | # furnished to do so, subject to the following conditions:
10 | #
11 | # The above copyright notice and this permission notice shall be included in
12 | # all copies or substantial portions of the Software.
13 | #
14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | # THE SOFTWARE.
21 | from __future__ import division
22 | import logging
23 | import time
24 |
25 | import Adafruit_GPIO as GPIO
26 | import Adafruit_GPIO.SPI as SPI
27 |
28 |
29 | # Constants
30 | SSD1306_I2C_ADDRESS = 0x3C # 011110+SA0+RW - 0x3C or 0x3D
31 | SSD1306_SETCONTRAST = 0x81
32 | SSD1306_DISPLAYALLON_RESUME = 0xA4
33 | SSD1306_DISPLAYALLON = 0xA5
34 | SSD1306_NORMALDISPLAY = 0xA6
35 | SSD1306_INVERTDISPLAY = 0xA7
36 | SSD1306_DISPLAYOFF = 0xAE
37 | SSD1306_DISPLAYON = 0xAF
38 | SSD1306_SETDISPLAYOFFSET = 0xD3
39 | SSD1306_SETCOMPINS = 0xDA
40 | SSD1306_SETVCOMDETECT = 0xDB
41 | SSD1306_SETDISPLAYCLOCKDIV = 0xD5
42 | SSD1306_SETPRECHARGE = 0xD9
43 | SSD1306_SETMULTIPLEX = 0xA8
44 | SSD1306_SETLOWCOLUMN = 0x00
45 | SSD1306_SETHIGHCOLUMN = 0x10
46 | SSD1306_SETSTARTLINE = 0x40
47 | SSD1306_MEMORYMODE = 0x20
48 | SSD1306_COLUMNADDR = 0x21
49 | SSD1306_PAGEADDR = 0x22
50 | SSD1306_COMSCANINC = 0xC0
51 | SSD1306_COMSCANDEC = 0xC8
52 | SSD1306_SEGREMAP = 0xA0
53 | SSD1306_CHARGEPUMP = 0x8D
54 | SSD1306_EXTERNALVCC = 0x1
55 | SSD1306_SWITCHCAPVCC = 0x2
56 |
57 | # Scrolling constants
58 | SSD1306_ACTIVATE_SCROLL = 0x2F
59 | SSD1306_DEACTIVATE_SCROLL = 0x2E
60 | SSD1306_SET_VERTICAL_SCROLL_AREA = 0xA3
61 | SSD1306_RIGHT_HORIZONTAL_SCROLL = 0x26
62 | SSD1306_LEFT_HORIZONTAL_SCROLL = 0x27
63 | SSD1306_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL = 0x29
64 | SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL = 0x2A
65 |
66 |
67 | class SSD1306Base(object):
68 | """Base class for SSD1306-based OLED displays. Implementors should subclass
69 | and provide an implementation for the _initialize function.
70 | """
71 |
72 | def __init__(self, width, height, rst, dc=None, sclk=None, din=None, cs=None,
73 | gpio=None, spi=None, i2c_bus=None, i2c_address=SSD1306_I2C_ADDRESS,
74 | i2c=None):
75 | self._log = logging.getLogger('Adafruit_SSD1306.SSD1306Base')
76 | self._spi = None
77 | self._i2c = None
78 | self.width = width
79 | self.height = height
80 | self._pages = height//8
81 | self._buffer = [0]*(width*self._pages)
82 | # Default to platform GPIO if not provided.
83 | self._gpio = gpio
84 | if self._gpio is None:
85 | self._gpio = GPIO.get_platform_gpio()
86 | # Setup reset pin.
87 | self._rst = rst
88 | if not self._rst is None:
89 | self._gpio.setup(self._rst, GPIO.OUT)
90 | # Handle hardware SPI
91 | if spi is not None:
92 | self._log.debug('Using hardware SPI')
93 | self._spi = spi
94 | self._spi.set_clock_hz(8000000)
95 | # Handle software SPI
96 | elif sclk is not None and din is not None and cs is not None:
97 | self._log.debug('Using software SPI')
98 | self._spi = SPI.BitBang(self._gpio, sclk, din, None, cs)
99 | # Handle hardware I2C
100 | elif i2c is not None:
101 | self._log.debug('Using hardware I2C with custom I2C provider.')
102 | self._i2c = i2c.get_i2c_device(i2c_address)
103 | else:
104 | self._log.debug('Using hardware I2C with platform I2C provider.')
105 | import Adafruit_GPIO.I2C as I2C
106 | if i2c_bus is None:
107 | self._i2c = I2C.get_i2c_device(i2c_address)
108 | else:
109 | self._i2c = I2C.get_i2c_device(i2c_address, busnum=i2c_bus)
110 | # Initialize DC pin if using SPI.
111 | if self._spi is not None:
112 | if dc is None:
113 | raise ValueError('DC pin must be provided when using SPI.')
114 | self._dc = dc
115 | self._gpio.setup(self._dc, GPIO.OUT)
116 |
117 | def _initialize(self):
118 | raise NotImplementedError
119 |
120 | def command(self, c):
121 | """Send command byte to display."""
122 | if self._spi is not None:
123 | # SPI write.
124 | self._gpio.set_low(self._dc)
125 | self._spi.write([c])
126 | else:
127 | # I2C write.
128 | control = 0x00 # Co = 0, DC = 0
129 | self._i2c.write8(control, c)
130 |
131 | def data(self, c):
132 | """Send byte of data to display."""
133 | if self._spi is not None:
134 | # SPI write.
135 | self._gpio.set_high(self._dc)
136 | self._spi.write([c])
137 | else:
138 | # I2C write.
139 | control = 0x40 # Co = 0, DC = 0
140 | self._i2c.write8(control, c)
141 |
142 | def begin(self, vccstate=SSD1306_SWITCHCAPVCC):
143 | """Initialize display."""
144 | # Save vcc state.
145 | self._vccstate = vccstate
146 | # Reset and initialize display.
147 | self.reset()
148 | self._initialize()
149 | # Turn on the display.
150 | self.command(SSD1306_DISPLAYON)
151 |
152 | def reset(self):
153 | """Reset the display."""
154 | if self._rst is None:
155 | return
156 | # Set reset high for a millisecond.
157 | self._gpio.set_high(self._rst)
158 | time.sleep(0.001)
159 | # Set reset low for 10 milliseconds.
160 | self._gpio.set_low(self._rst)
161 | time.sleep(0.010)
162 | # Set reset high again.
163 | self._gpio.set_high(self._rst)
164 |
165 | def display(self):
166 | """Write display buffer to physical display."""
167 | # Write buffer data.
168 | if self._spi is not None:
169 | # Set DC high for data.
170 | self._gpio.set_high(self._dc)
171 | # Write buffer.
172 | self._spi.write(self._buffer)
173 | else:
174 | pg=0
175 | for i in range(0, len(self._buffer), 128):
176 | self.command(0xB0 + pg) # SSD1306_COLUMNADDR
177 | self.command(0x00) # Column start address. (0 = reset)
178 | self.command(0x10) # Column end address.
179 | control = 0x40 # Co = 0, DC = 0
180 | self._i2c.writeList(control, self._buffer[i:i+128])
181 | pg = pg + 1
182 | def image(self, image):
183 | """Set buffer to value of Python Imaging Library image. The image should
184 | be in 1 bit mode and a size equal to the display size.
185 | """
186 | if image.mode != '1':
187 | raise ValueError('Image must be in mode 1.')
188 | imwidth, imheight = image.size
189 | if imwidth != self.width or imheight != self.height:
190 | raise ValueError('Image must be same dimensions as display ({0}x{1}).' \
191 | .format(self.width, self.height))
192 | # Grab all the pixels from the image, faster than getpixel.
193 | pix = image.load()
194 | # Iterate through the memory pages
195 | index = 0
196 | for page in range(self._pages):
197 | # Iterate through all x axis columns.
198 | for x in range(self.width):
199 | # Set the bits for the column of pixels at the current position.
200 | bits = 0
201 | # Don't use range here as it's a bit slow
202 | for bit in [0, 1, 2, 3, 4, 5, 6, 7]:
203 | bits = bits << 1
204 | bits |= 0 if pix[(x, page*8+7-bit)] == 0 else 1
205 | # Update buffer byte and increment to next byte.
206 | self._buffer[index] = bits
207 | index += 1
208 |
209 | def clear(self):
210 | """Clear contents of image buffer."""
211 | self._buffer = [0x0f]*(self.width*self._pages)
212 |
213 | def set_contrast(self, contrast):
214 | """Sets the contrast of the display. Contrast should be a value between
215 | 0 and 255."""
216 | if contrast < 0 or contrast > 255:
217 | raise ValueError('Contrast must be a value from 0 to 255 (inclusive).')
218 | self.command(SSD1306_SETCONTRAST)
219 | self.command(contrast)
220 |
221 | def dim(self, dim):
222 | """Adjusts contrast to dim the display if dim is True, otherwise sets the
223 | contrast to normal brightness if dim is False.
224 | """
225 | # Assume dim display.
226 | contrast = 0
227 | # Adjust contrast based on VCC if not dimming.
228 | if not dim:
229 | if self._vccstate == SSD1306_EXTERNALVCC:
230 | contrast = 0x9F
231 | else:
232 | contrast = 0xCF
233 | self.set_contrast(contrast)
234 |
235 | class SSD1306_128_64(SSD1306Base):
236 | def __init__(self, rst, dc=None, sclk=None, din=None, cs=None, gpio=None,
237 | spi=None, i2c_bus=None, i2c_address=SSD1306_I2C_ADDRESS,
238 | i2c=None):
239 | # Call base class constructor.
240 | super(SSD1306_128_64, self).__init__(128, 64, rst, dc, sclk, din, cs,
241 | gpio, spi, i2c_bus, i2c_address, i2c)
242 |
243 | def _initialize(self):
244 | # 128x64 pixel specific initialization.
245 | self.command(SSD1306_DISPLAYOFF) # 0xAE
246 | self.command(SSD1306_SETDISPLAYCLOCKDIV) # 0xD5
247 | self.command(0x80) # the suggested ratio 0x80
248 | self.command(SSD1306_SETMULTIPLEX) # 0xA8
249 | self.command(0x3F)
250 | self.command(SSD1306_SETDISPLAYOFFSET) # 0xD3
251 | self.command(0x0) # no offset
252 | self.command(SSD1306_SETSTARTLINE | 0x0) # line #0
253 | self.command(SSD1306_CHARGEPUMP) # 0x8D
254 | #self.command(0x32) # 0x8D
255 | if self._vccstate == SSD1306_EXTERNALVCC:
256 | self.command(0x10)
257 | else:
258 | self.command(0x14)
259 | self.command(SSD1306_MEMORYMODE) # 0x20
260 | self.command(0x00) # 0x0 act like ks0108
261 | self.command(SSD1306_SEGREMAP | 0x1)
262 | self.command(SSD1306_COMSCANDEC)
263 | self.command(SSD1306_SETCOMPINS) # 0xDA
264 | self.command(0x12)
265 | self.command(SSD1306_SETCONTRAST) # 0x81
266 | if self._vccstate == SSD1306_EXTERNALVCC:
267 | self.command(0x9F)
268 | else:
269 | self.command(0xCF)
270 | self.command(SSD1306_SETPRECHARGE) # 0xd9
271 | if self._vccstate == SSD1306_EXTERNALVCC:
272 | self.command(0x22)
273 | else:
274 | self.command(0xF1)
275 | self.command(SSD1306_SETVCOMDETECT) # 0xDB
276 | self.command(0x40)
277 | self.command(SSD1306_DISPLAYALLON_RESUME) # 0xA4
278 | self.command(SSD1306_NORMALDISPLAY) # 0xA6
279 |
280 |
281 | class SSD1306_128_32(SSD1306Base):
282 | def __init__(self, rst, dc=None, sclk=None, din=None, cs=None, gpio=None,
283 | spi=None, i2c_bus=None, i2c_address=SSD1306_I2C_ADDRESS,
284 | i2c=None):
285 | # Call base class constructor.
286 | super(SSD1306_128_32, self).__init__(128, 32, rst, dc, sclk, din, cs,
287 | gpio, spi, i2c_bus, i2c_address, i2c)
288 |
289 | def _initialize(self):
290 | # 128x32 pixel specific initialization.
291 | self.command(SSD1306_DISPLAYOFF) # 0xAE
292 | self.command(SSD1306_SETDISPLAYCLOCKDIV) # 0xD5 set osc division
293 | self.command(0xB1) # the suggested ratio 0x80
294 | self.command(SSD1306_SETMULTIPLEX) # 0xA8
295 | self.command(0x1F)
296 | self.command(SSD1306_SETDISPLAYOFFSET) # 0xD3
297 | self.command(0x10)
298 | self.command(SSD1306_SETSTARTLINE | 0x0) # line SSD1306_SETSTARTLINE = 0x40
299 | self.command(SSD1306_SEGREMAP | 0x1) # SSD1306_SEGREMAP = 0xA0
300 | self.command(SSD1306_COMSCANDEC) # SSD1306_COMSCANDEC = 0xC8
301 | self.command(0x82)
302 | self.command(0x00)
303 | self.command(SSD1306_SETCONTRAST) # 0x81
304 | self.command(0x4D)
305 | self.command(SSD1306_SETPRECHARGE) # 0xd9
306 | self.command(0x62)
307 | self.command(SSD1306_SETVCOMDETECT) # 0xDB
308 | self.command(0x3F)
309 | self.command(SSD1306_DISPLAYALLON_RESUME) # 0xA4
310 | self.command(SSD1306_NORMALDISPLAY) # 0xA6
311 | #self.command(0x32) # PUMP Voltage default value =0x32 SSD1306_CHARGEPUMP = 0x8D
312 | self.command(0xAD) # PUMP On/Off
313 | self.command(0x8B)
314 | self.command(0xAF)
315 |
316 | #self.command(0x00)
317 | #self.command(0x10) # no offset
318 | #self.command(0xB0) # set page address
319 |
320 |
321 |
322 |
323 |
324 | class SSD1306_96_16(SSD1306Base):
325 | def __init__(self, rst, dc=None, sclk=None, din=None, cs=None, gpio=None,
326 | spi=None, i2c_bus=None, i2c_address=SSD1306_I2C_ADDRESS,
327 | i2c=None):
328 | # Call base class constructor.
329 | super(SSD1306_96_16, self).__init__(96, 16, rst, dc, sclk, din, cs,
330 | gpio, spi, i2c_bus, i2c_address, i2c)
331 |
332 | def _initialize(self):
333 | # 128x32 pixel specific initialization.
334 | self.command(SSD1306_DISPLAYOFF) # 0xAE
335 | self.command(SSD1306_SETDISPLAYCLOCKDIV) # 0xD5
336 | self.command(0x60) # the suggested ratio 0x60
337 | self.command(SSD1306_SETMULTIPLEX) # 0xA8
338 | self.command(0x0F)
339 | self.command(SSD1306_SETDISPLAYOFFSET) # 0xD3
340 | self.command(0x0) # no offset
341 | self.command(SSD1306_SETSTARTLINE | 0x0) # line #0
342 | self.command(SSD1306_CHARGEPUMP) # 0x8D
343 | if self._vccstate == SSD1306_EXTERNALVCC:
344 | self.command(0x10)
345 | else:
346 | self.command(0x14)
347 | self.command(SSD1306_MEMORYMODE) # 0x20
348 | self.command(0x00) # 0x0 act like ks0108
349 | self.command(SSD1306_SEGREMAP | 0x1)
350 | self.command(SSD1306_COMSCANDEC)
351 | self.command(SSD1306_SETCOMPINS) # 0xDA
352 | self.command(0x02)
353 | self.command(SSD1306_SETCONTRAST) # 0x81
354 | self.command(0x8F)
355 | self.command(SSD1306_SETPRECHARGE) # 0xd9
356 | if self._vccstate == SSD1306_EXTERNALVCC:
357 | self.command(0x22)
358 | else:
359 | self.command(0xF1)
360 | self.command(SSD1306_SETVCOMDETECT) # 0xDB
361 | self.command(0x40)
362 | self.command(SSD1306_DISPLAYALLON_RESUME) # 0xA4
363 | self.command(SSD1306_NORMALDISPLAY) # 0xA6
364 |
--------------------------------------------------------------------------------
/NBX_OLED/__init__.py:
--------------------------------------------------------------------------------
1 | from .OLED import *
2 |
--------------------------------------------------------------------------------
/Nabaixin_TFOLED.egg-info/PKG-INFO:
--------------------------------------------------------------------------------
1 | Metadata-Version: 1.1
2 | Name: Nabaixin-TFOLED
3 | Version: 1.0.2
4 | Summary: Python library to use RTC Fan OLED board for a Raspberry Pi or Beaglebone Black.
5 | Home-page: https://github.com/nabaixin/TFOLED/
6 | Author: Nabaixin.com
7 | Author-email: nabaixin@163.com
8 | License: MIT
9 | Description:
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 | TFO/README.md at master · Nabaixin/TFO
41 |
42 |
43 |
44 |
45 |
46 |
47 |
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 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
664 |
665 |
666 |
667 |
668 |
669 |
670 |
671 |
672 |
673 |
674 |
675 |
676 |
677 |
678 |
679 |
680 |
681 |
682 |
683 |
684 |
685 |
686 |
687 |
688 |
689 |
690 |
691 |
692 |
693 |
694 |
700 |
701 |
702 |
703 |
704 |
705 |
706 |
707 |
708 |
709 |
Learn Git and GitHub without any code!
710 |
711 | Using the Hello World guide, you’ll start a branch, write comments, and open a pull request.
712 |
713 |
Read the guide
714 |
715 |
719 |
720 |
721 |
722 |
723 |
724 |
725 |
726 |
727 |
728 |
729 |
730 |
731 |
732 |
733 |
734 |
735 |
736 |
737 |
738 | Nabaixin
739 |
740 | /
741 |
742 | TFO
743 |
744 |
745 |
746 |
747 |
748 |
749 |
750 |
751 |
752 |
753 |
824 |
825 |
826 |
827 |
846 |
847 |
848 |
849 |
850 |
854 |
856 | 0
857 |
858 |
859 |
860 |
861 |
862 |
863 |
864 |
915 |
916 |
917 |
921 |
922 |
960 |
961 |
962 |
963 |
964 |
965 |
966 |
967 |
968 |
969 |
970 |
971 |
972 |
973 |
Permalink
974 |
975 |
976 |
977 |
978 |
979 |
980 |
997 |
998 |
999 | TFO / README.md
1000 |
1001 |
1005 | Go to file
1006 |
1007 |
1008 |
1009 |
1010 |
1011 |
1012 |
1013 |
1014 |
1035 |
1036 |
1037 |
1038 |
1039 |
1040 |
1041 |
1042 |
1046 |
1047 |
1048 |
1049 |
Cannot retrieve contributors at this time
1050 |
1051 |
1052 |
1053 |
1054 |
1055 |
1056 |
1057 |
1058 |
1060 |
1061 |
1062 |
1063 |
1064 | 2 lines (2 sloc)
1065 |
1066 | 76 Bytes
1067 |
1068 |
1069 |
1070 |
1071 |
1075 |
1076 |
1097 |
1098 |
1099 |
1100 |
1101 |
1102 |
1103 |
1104 |
TFO
1105 | RTC, Fan, OLED for Raspberry Pi, all stuff needed as a stable server.
1106 |
1107 |
1108 |
1109 |
1110 |
1111 |
1112 |
1113 |
1114 |
1115 |
1116 |
1117 |
1121 |
1122 |
1123 |
1136 |
1137 |
1138 |
1139 |
1140 |
1141 |
1142 |
1143 |
1144 |
1145 |
1146 |
1147 |
1148 |
1149 |
1150 |
1178 |
1179 |
1180 |
1181 |
1182 |
1183 |
1184 |
1185 |
1186 | You can’t perform that action at this time.
1187 |
1188 |
1189 |
1190 |
1191 |
1192 |
1193 |
1194 |
1195 |
1196 |
1197 |
1198 |
1199 |
1200 |
1201 |
1202 |
1203 |
1204 |
1205 |
1206 |
1207 |
1208 |
1209 |
1211 |
1212 |
You signed in with another tab or window. Reload to refresh your session.
1213 |
You signed out in another tab or window. Reload to refresh your session.
1214 |
1215 |
1216 |
1217 |
1218 |
1219 |
1220 |
1221 |
1222 |
1223 |
1224 |
1225 |
1226 |
1227 |
1231 |
1232 |
1233 |
1234 |
1235 |
1236 |
1237 | Platform: UNKNOWN
1238 | Classifier: Development Status :: 4 - Beta
1239 | Classifier: Operating System :: POSIX :: Linux
1240 | Classifier: License :: OSI Approved :: MIT License
1241 | Classifier: Intended Audience :: Developers
1242 | Classifier: Programming Language :: Python :: 2.7
1243 | Classifier: Programming Language :: Python :: 3.7
1244 | Classifier: Topic :: Software Development
1245 | Classifier: Topic :: System :: Hardware
1246 |
--------------------------------------------------------------------------------
/Nabaixin_TFOLED.egg-info/SOURCES.txt:
--------------------------------------------------------------------------------
1 | README.md
2 | setup.py
3 | NBX_OLED/OLED.py
4 | NBX_OLED/__init__.py
5 | Nabaixin_TFOLED.egg-info/PKG-INFO
6 | Nabaixin_TFOLED.egg-info/SOURCES.txt
7 | Nabaixin_TFOLED.egg-info/dependency_links.txt
8 | Nabaixin_TFOLED.egg-info/requires.txt
9 | Nabaixin_TFOLED.egg-info/top_level.txt
--------------------------------------------------------------------------------
/Nabaixin_TFOLED.egg-info/dependency_links.txt:
--------------------------------------------------------------------------------
1 | https://github.com/adafruit/Adafruit_Python_GPIO/tarball/master#egg=Adafruit-GPIO-0.6.5
2 |
--------------------------------------------------------------------------------
/Nabaixin_TFOLED.egg-info/requires.txt:
--------------------------------------------------------------------------------
1 | Adafruit-GPIO>=0.6.5
2 |
--------------------------------------------------------------------------------
/Nabaixin_TFOLED.egg-info/top_level.txt:
--------------------------------------------------------------------------------
1 | NBX_OLED
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | This project is driver and usage of Nabaixin TFOLED, a HAT breakout for raspberry pi including Timer, Fan driver, OLED display.
2 | [Follow the Chinese Link(中文说明)](https://www.jianshu.com/p/0bcf3dde7048)
3 |
4 | 
5 |
6 |
7 |
8 | 唯一官方淘宝店:[https://keliu.taobao.com/](https://keliu.taobao.com/)
9 |
--------------------------------------------------------------------------------
/Readme_img/readme img.txt:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/TFOL.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2017 Adafruit Industries
2 | # Author: Tony DiCola & James DeVito
3 | #
4 | # Permission is hereby granted, free of charge, to any person obtaining a copy
5 | # of this software and associated documentation files (the "Software"), to deal
6 | # in the Software without restriction, including without limitation the rights
7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | # copies of the Software, and to permit persons to whom the Software is
9 | # furnished to do so, subject to the following conditions:
10 | #
11 | # The above copyright notice and this permission notice shall be included in
12 | # all copies or substantial portions of the Software.
13 | #
14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | # THE SOFTWARE.
21 | import time
22 | import RPi.GPIO
23 | import NBX_OLED
24 | import json
25 |
26 |
27 | from PIL import Image
28 | from PIL import ImageDraw
29 | from PIL import ImageFont
30 |
31 | import subprocess
32 |
33 | RPi.GPIO.setmode(RPi.GPIO.BCM)
34 | RPi.GPIO.setwarnings(False)
35 | RPi.GPIO.setup(4, RPi.GPIO.OUT)
36 | RPi.GPIO.output(4, True)
37 | # Raspberry Pi pin configuration:
38 | RST = None # on the PiOLED this pin isnt used
39 | # Note the following are only used with SPI:
40 | DC = 23
41 | SPI_PORT = 0
42 | SPI_DEVICE = 0
43 |
44 | # Beaglebone Black pin configuration:
45 | # RST = 'P9_12'
46 | # Note the following are only used with SPI:
47 | # DC = 'P9_15'
48 | # SPI_PORT = 1
49 | # SPI_DEVICE = 0
50 |
51 | # 128x32 display with hardware I2C:
52 | disp = NBX_OLED.SSD1306_128_32(rst=RST)
53 |
54 | # 128x64 display with hardware I2C:
55 | # disp = Adafruit_SSD1306.SSD1306_128_64(rst=RST)
56 |
57 | # Note you can change the I2C address by passing an i2c_address parameter like:
58 | # disp = Adafruit_SSD1306.SSD1306_128_64(rst=RST, i2c_address=0x3C)
59 |
60 | # Alternatively you can specify an explicit I2C bus number, for example
61 | # with the 128x32 display you would use:
62 | # disp = Adafruit_SSD1306.SSD1306_128_32(rst=RST, i2c_bus=2)
63 |
64 | # 128x32 display with hardware SPI:
65 | # disp = Adafruit_SSD1306.SSD1306_128_32(rst=RST, dc=DC, spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE, max_speed_hz=8000000))
66 |
67 | # 128x64 display with hardware SPI:
68 | # disp = Adafruit_SSD1306.SSD1306_128_64(rst=RST, dc=DC, spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE, max_speed_hz=8000000))
69 |
70 | # Alternatively you can specify a software SPI implementation by providing
71 | # digital GPIO pin numbers for all the required display pins. For example
72 | # on a Raspberry Pi with the 128x32 display you might use:
73 | # disp = Adafruit_SSD1306.SSD1306_128_32(rst=RST, dc=DC, sclk=18, din=25, cs=22)
74 |
75 | # Initialize library.
76 | disp.begin()
77 |
78 | # Clear display.
79 | disp.clear()
80 | disp.display()
81 |
82 | # Create blank image for drawing.
83 | # Make sure to create image with mode '1' for 1-bit color.
84 | width = disp.width
85 | height = disp.height
86 | image = Image.new('1', (width, height))
87 |
88 | # Get drawing object to draw on image.
89 | draw = ImageDraw.Draw(image)
90 |
91 | # Draw a black filled box to clear the image.
92 | draw.rectangle((0,0,width,height), outline=0, fill=0)
93 |
94 | # Draw some shapes.
95 | # First define some constants to allow easy resizing of shapes.
96 | padding = -2
97 | top = padding
98 | bottom = height-padding
99 | # Move left to right keeping track of the current x position for drawing shapes.
100 | x = 0
101 |
102 |
103 | # Load default font.
104 | font = ImageFont.load_default()
105 |
106 | # Alternatively load a TTF font. Make sure the .ttf font file is in the same directory as the python script!
107 | # Some other nice fonts to try: http://www.dafont.com/bitmap.php
108 | # font = ImageFont.truetype('Minecraftia.ttf', 8)
109 |
110 | while True:
111 |
112 | # Draw a black filled box to clear the image.
113 | draw.rectangle((0,0,width,height), outline=0, fill=0)
114 | #f = open('/home/pi/ppl/data/snapshot.db', 'r')
115 | #sj = f.read()
116 | #str_json = json.loads(sj)
117 | #stct = str_json["StayCount"]
118 | #tti = str_json["TodayTotalIn"]
119 | #tto = str_json["TodayTotalOut"]
120 | # Shell scripts for system monitoring from here : https://unix.stackexchange.com/questions/119126/command-to-display-memory-usage-disk-usage-and-cpu-load
121 | cmd = "cat /sys/class/thermal/thermal_zone0/temp"
122 | tmpcore = int(subprocess.check_output(cmd, shell = True ))
123 | if(tmpcore > 60000) :
124 | RPi.GPIO.output(4, True)
125 | if(tmpcore < 45000) :
126 | RPi.GPIO.output(4, False)
127 | cmd = "hostname -I | cut -d\' \' -f1"
128 | IP = subprocess.check_output(cmd, shell = True )
129 | cmd = "top -bn1 | grep load | awk '{printf (\"CPU:%.2f\", $(NF-2))}'"
130 | CPU = subprocess.check_output(cmd, shell = True )
131 | cmd = "free -m | awk 'NR==2{printf (\"Mem:%s/%sM\", $3,$2) }'"
132 | MemUsage = subprocess.check_output(cmd, shell = True )
133 | cmd = "df -h | awk '$NF==\"/\"{printf (\" D:%d/%dG\", $3,$2)}'"
134 | Disk = subprocess.check_output(cmd, shell = True )
135 | lt = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
136 | # Write two lines of text.
137 | draw.rectangle((0,0,width,height), outline=0, fill=0)
138 |
139 | draw.text((x, top), lt, font=font, fill=255) #"T:" +
140 | draw.text((x, top+8), "IP: " + str(IP.decode('utf8').strip()).strip('b'), font=font, fill=255)
141 | draw.text((x, top+16), str(CPU.decode('utf8').strip()).strip('b') + " CT:" + str(tmpcore/1000), font=font, fill=255)
142 | draw.text((x, top+25), str(MemUsage.decode('utf8').strip()).strip('b') + " " + str(Disk.decode('utf8').strip()).strip('b'), font=font, fill=255)
143 | # Display image.
144 | disp.image(image)
145 | disp.display()
146 | time.sleep(1)
147 |
148 |
--------------------------------------------------------------------------------
/build/lib/NBX_OLED/OLED.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2020
2 | # Author: FrankVon
3 | #
4 | # Permission is hereby granted, free of charge, to any person obtaining a copy
5 | # of this software and associated documentation files (the "Software"), to deal
6 | # in the Software without restriction, including without limitation the rights
7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | # copies of the Software, and to permit persons to whom the Software is
9 | # furnished to do so, subject to the following conditions:
10 | #
11 | # The above copyright notice and this permission notice shall be included in
12 | # all copies or substantial portions of the Software.
13 | #
14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | # THE SOFTWARE.
21 | from __future__ import division
22 | import logging
23 | import time
24 |
25 | import Adafruit_GPIO as GPIO
26 | import Adafruit_GPIO.SPI as SPI
27 |
28 |
29 | # Constants
30 | SSD1306_I2C_ADDRESS = 0x3C # 011110+SA0+RW - 0x3C or 0x3D
31 | SSD1306_SETCONTRAST = 0x81
32 | SSD1306_DISPLAYALLON_RESUME = 0xA4
33 | SSD1306_DISPLAYALLON = 0xA5
34 | SSD1306_NORMALDISPLAY = 0xA6
35 | SSD1306_INVERTDISPLAY = 0xA7
36 | SSD1306_DISPLAYOFF = 0xAE
37 | SSD1306_DISPLAYON = 0xAF
38 | SSD1306_SETDISPLAYOFFSET = 0xD3
39 | SSD1306_SETCOMPINS = 0xDA
40 | SSD1306_SETVCOMDETECT = 0xDB
41 | SSD1306_SETDISPLAYCLOCKDIV = 0xD5
42 | SSD1306_SETPRECHARGE = 0xD9
43 | SSD1306_SETMULTIPLEX = 0xA8
44 | SSD1306_SETLOWCOLUMN = 0x00
45 | SSD1306_SETHIGHCOLUMN = 0x10
46 | SSD1306_SETSTARTLINE = 0x40
47 | SSD1306_MEMORYMODE = 0x20
48 | SSD1306_COLUMNADDR = 0x21
49 | SSD1306_PAGEADDR = 0x22
50 | SSD1306_COMSCANINC = 0xC0
51 | SSD1306_COMSCANDEC = 0xC8
52 | SSD1306_SEGREMAP = 0xA0
53 | SSD1306_CHARGEPUMP = 0x8D
54 | SSD1306_EXTERNALVCC = 0x1
55 | SSD1306_SWITCHCAPVCC = 0x2
56 |
57 | # Scrolling constants
58 | SSD1306_ACTIVATE_SCROLL = 0x2F
59 | SSD1306_DEACTIVATE_SCROLL = 0x2E
60 | SSD1306_SET_VERTICAL_SCROLL_AREA = 0xA3
61 | SSD1306_RIGHT_HORIZONTAL_SCROLL = 0x26
62 | SSD1306_LEFT_HORIZONTAL_SCROLL = 0x27
63 | SSD1306_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL = 0x29
64 | SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL = 0x2A
65 |
66 |
67 | class SSD1306Base(object):
68 | """Base class for SSD1306-based OLED displays. Implementors should subclass
69 | and provide an implementation for the _initialize function.
70 | """
71 |
72 | def __init__(self, width, height, rst, dc=None, sclk=None, din=None, cs=None,
73 | gpio=None, spi=None, i2c_bus=None, i2c_address=SSD1306_I2C_ADDRESS,
74 | i2c=None):
75 | self._log = logging.getLogger('Adafruit_SSD1306.SSD1306Base')
76 | self._spi = None
77 | self._i2c = None
78 | self.width = width
79 | self.height = height
80 | self._pages = height//8
81 | self._buffer = [0]*(width*self._pages)
82 | # Default to platform GPIO if not provided.
83 | self._gpio = gpio
84 | if self._gpio is None:
85 | self._gpio = GPIO.get_platform_gpio()
86 | # Setup reset pin.
87 | self._rst = rst
88 | if not self._rst is None:
89 | self._gpio.setup(self._rst, GPIO.OUT)
90 | # Handle hardware SPI
91 | if spi is not None:
92 | self._log.debug('Using hardware SPI')
93 | self._spi = spi
94 | self._spi.set_clock_hz(8000000)
95 | # Handle software SPI
96 | elif sclk is not None and din is not None and cs is not None:
97 | self._log.debug('Using software SPI')
98 | self._spi = SPI.BitBang(self._gpio, sclk, din, None, cs)
99 | # Handle hardware I2C
100 | elif i2c is not None:
101 | self._log.debug('Using hardware I2C with custom I2C provider.')
102 | self._i2c = i2c.get_i2c_device(i2c_address)
103 | else:
104 | self._log.debug('Using hardware I2C with platform I2C provider.')
105 | import Adafruit_GPIO.I2C as I2C
106 | if i2c_bus is None:
107 | self._i2c = I2C.get_i2c_device(i2c_address)
108 | else:
109 | self._i2c = I2C.get_i2c_device(i2c_address, busnum=i2c_bus)
110 | # Initialize DC pin if using SPI.
111 | if self._spi is not None:
112 | if dc is None:
113 | raise ValueError('DC pin must be provided when using SPI.')
114 | self._dc = dc
115 | self._gpio.setup(self._dc, GPIO.OUT)
116 |
117 | def _initialize(self):
118 | raise NotImplementedError
119 |
120 | def command(self, c):
121 | """Send command byte to display."""
122 | if self._spi is not None:
123 | # SPI write.
124 | self._gpio.set_low(self._dc)
125 | self._spi.write([c])
126 | else:
127 | # I2C write.
128 | control = 0x00 # Co = 0, DC = 0
129 | self._i2c.write8(control, c)
130 |
131 | def data(self, c):
132 | """Send byte of data to display."""
133 | if self._spi is not None:
134 | # SPI write.
135 | self._gpio.set_high(self._dc)
136 | self._spi.write([c])
137 | else:
138 | # I2C write.
139 | control = 0x40 # Co = 0, DC = 0
140 | self._i2c.write8(control, c)
141 |
142 | def begin(self, vccstate=SSD1306_SWITCHCAPVCC):
143 | """Initialize display."""
144 | # Save vcc state.
145 | self._vccstate = vccstate
146 | # Reset and initialize display.
147 | self.reset()
148 | self._initialize()
149 | # Turn on the display.
150 | self.command(SSD1306_DISPLAYON)
151 |
152 | def reset(self):
153 | """Reset the display."""
154 | if self._rst is None:
155 | return
156 | # Set reset high for a millisecond.
157 | self._gpio.set_high(self._rst)
158 | time.sleep(0.001)
159 | # Set reset low for 10 milliseconds.
160 | self._gpio.set_low(self._rst)
161 | time.sleep(0.010)
162 | # Set reset high again.
163 | self._gpio.set_high(self._rst)
164 |
165 | def display(self):
166 | """Write display buffer to physical display."""
167 | # Write buffer data.
168 | if self._spi is not None:
169 | # Set DC high for data.
170 | self._gpio.set_high(self._dc)
171 | # Write buffer.
172 | self._spi.write(self._buffer)
173 | else:
174 | pg=0
175 | for i in range(0, len(self._buffer), 128):
176 | self.command(0xB0 + pg) # SSD1306_COLUMNADDR
177 | self.command(0x00) # Column start address. (0 = reset)
178 | self.command(0x10) # Column end address.
179 | control = 0x40 # Co = 0, DC = 0
180 | self._i2c.writeList(control, self._buffer[i:i+128])
181 | pg = pg + 1
182 | def image(self, image):
183 | """Set buffer to value of Python Imaging Library image. The image should
184 | be in 1 bit mode and a size equal to the display size.
185 | """
186 | if image.mode != '1':
187 | raise ValueError('Image must be in mode 1.')
188 | imwidth, imheight = image.size
189 | if imwidth != self.width or imheight != self.height:
190 | raise ValueError('Image must be same dimensions as display ({0}x{1}).' \
191 | .format(self.width, self.height))
192 | # Grab all the pixels from the image, faster than getpixel.
193 | pix = image.load()
194 | # Iterate through the memory pages
195 | index = 0
196 | for page in range(self._pages):
197 | # Iterate through all x axis columns.
198 | for x in range(self.width):
199 | # Set the bits for the column of pixels at the current position.
200 | bits = 0
201 | # Don't use range here as it's a bit slow
202 | for bit in [0, 1, 2, 3, 4, 5, 6, 7]:
203 | bits = bits << 1
204 | bits |= 0 if pix[(x, page*8+7-bit)] == 0 else 1
205 | # Update buffer byte and increment to next byte.
206 | self._buffer[index] = bits
207 | index += 1
208 |
209 | def clear(self):
210 | """Clear contents of image buffer."""
211 | self._buffer = [0x0f]*(self.width*self._pages)
212 |
213 | def set_contrast(self, contrast):
214 | """Sets the contrast of the display. Contrast should be a value between
215 | 0 and 255."""
216 | if contrast < 0 or contrast > 255:
217 | raise ValueError('Contrast must be a value from 0 to 255 (inclusive).')
218 | self.command(SSD1306_SETCONTRAST)
219 | self.command(contrast)
220 |
221 | def dim(self, dim):
222 | """Adjusts contrast to dim the display if dim is True, otherwise sets the
223 | contrast to normal brightness if dim is False.
224 | """
225 | # Assume dim display.
226 | contrast = 0
227 | # Adjust contrast based on VCC if not dimming.
228 | if not dim:
229 | if self._vccstate == SSD1306_EXTERNALVCC:
230 | contrast = 0x9F
231 | else:
232 | contrast = 0xCF
233 | self.set_contrast(contrast)
234 |
235 | class SSD1306_128_64(SSD1306Base):
236 | def __init__(self, rst, dc=None, sclk=None, din=None, cs=None, gpio=None,
237 | spi=None, i2c_bus=None, i2c_address=SSD1306_I2C_ADDRESS,
238 | i2c=None):
239 | # Call base class constructor.
240 | super(SSD1306_128_64, self).__init__(128, 64, rst, dc, sclk, din, cs,
241 | gpio, spi, i2c_bus, i2c_address, i2c)
242 |
243 | def _initialize(self):
244 | # 128x64 pixel specific initialization.
245 | self.command(SSD1306_DISPLAYOFF) # 0xAE
246 | self.command(SSD1306_SETDISPLAYCLOCKDIV) # 0xD5
247 | self.command(0x80) # the suggested ratio 0x80
248 | self.command(SSD1306_SETMULTIPLEX) # 0xA8
249 | self.command(0x3F)
250 | self.command(SSD1306_SETDISPLAYOFFSET) # 0xD3
251 | self.command(0x0) # no offset
252 | self.command(SSD1306_SETSTARTLINE | 0x0) # line #0
253 | self.command(SSD1306_CHARGEPUMP) # 0x8D
254 | #self.command(0x32) # 0x8D
255 | if self._vccstate == SSD1306_EXTERNALVCC:
256 | self.command(0x10)
257 | else:
258 | self.command(0x14)
259 | self.command(SSD1306_MEMORYMODE) # 0x20
260 | self.command(0x00) # 0x0 act like ks0108
261 | self.command(SSD1306_SEGREMAP | 0x1)
262 | self.command(SSD1306_COMSCANDEC)
263 | self.command(SSD1306_SETCOMPINS) # 0xDA
264 | self.command(0x12)
265 | self.command(SSD1306_SETCONTRAST) # 0x81
266 | if self._vccstate == SSD1306_EXTERNALVCC:
267 | self.command(0x9F)
268 | else:
269 | self.command(0xCF)
270 | self.command(SSD1306_SETPRECHARGE) # 0xd9
271 | if self._vccstate == SSD1306_EXTERNALVCC:
272 | self.command(0x22)
273 | else:
274 | self.command(0xF1)
275 | self.command(SSD1306_SETVCOMDETECT) # 0xDB
276 | self.command(0x40)
277 | self.command(SSD1306_DISPLAYALLON_RESUME) # 0xA4
278 | self.command(SSD1306_NORMALDISPLAY) # 0xA6
279 |
280 |
281 | class SSD1306_128_32(SSD1306Base):
282 | def __init__(self, rst, dc=None, sclk=None, din=None, cs=None, gpio=None,
283 | spi=None, i2c_bus=None, i2c_address=SSD1306_I2C_ADDRESS,
284 | i2c=None):
285 | # Call base class constructor.
286 | super(SSD1306_128_32, self).__init__(128, 32, rst, dc, sclk, din, cs,
287 | gpio, spi, i2c_bus, i2c_address, i2c)
288 |
289 | def _initialize(self):
290 | # 128x32 pixel specific initialization.
291 | self.command(SSD1306_DISPLAYOFF) # 0xAE
292 | self.command(SSD1306_SETDISPLAYCLOCKDIV) # 0xD5 set osc division
293 | self.command(0xB1) # the suggested ratio 0x80
294 | self.command(SSD1306_SETMULTIPLEX) # 0xA8
295 | self.command(0x1F)
296 | self.command(SSD1306_SETDISPLAYOFFSET) # 0xD3
297 | self.command(0x10)
298 | self.command(SSD1306_SETSTARTLINE | 0x0) # line SSD1306_SETSTARTLINE = 0x40
299 | self.command(SSD1306_SEGREMAP | 0x1) # SSD1306_SEGREMAP = 0xA0
300 | self.command(SSD1306_COMSCANDEC) # SSD1306_COMSCANDEC = 0xC8
301 | self.command(0x82)
302 | self.command(0x00)
303 | self.command(SSD1306_SETCONTRAST) # 0x81
304 | self.command(0x4D)
305 | self.command(SSD1306_SETPRECHARGE) # 0xd9
306 | self.command(0x62)
307 | self.command(SSD1306_SETVCOMDETECT) # 0xDB
308 | self.command(0x3F)
309 | self.command(SSD1306_DISPLAYALLON_RESUME) # 0xA4
310 | self.command(SSD1306_NORMALDISPLAY) # 0xA6
311 | #self.command(0x32) # PUMP Voltage default value =0x32 SSD1306_CHARGEPUMP = 0x8D
312 | self.command(0xAD) # PUMP On/Off
313 | self.command(0x8B)
314 | self.command(0xAF)
315 |
316 | #self.command(0x00)
317 | #self.command(0x10) # no offset
318 | #self.command(0xB0) # set page address
319 |
320 |
321 |
322 |
323 |
324 | class SSD1306_96_16(SSD1306Base):
325 | def __init__(self, rst, dc=None, sclk=None, din=None, cs=None, gpio=None,
326 | spi=None, i2c_bus=None, i2c_address=SSD1306_I2C_ADDRESS,
327 | i2c=None):
328 | # Call base class constructor.
329 | super(SSD1306_96_16, self).__init__(96, 16, rst, dc, sclk, din, cs,
330 | gpio, spi, i2c_bus, i2c_address, i2c)
331 |
332 | def _initialize(self):
333 | # 128x32 pixel specific initialization.
334 | self.command(SSD1306_DISPLAYOFF) # 0xAE
335 | self.command(SSD1306_SETDISPLAYCLOCKDIV) # 0xD5
336 | self.command(0x60) # the suggested ratio 0x60
337 | self.command(SSD1306_SETMULTIPLEX) # 0xA8
338 | self.command(0x0F)
339 | self.command(SSD1306_SETDISPLAYOFFSET) # 0xD3
340 | self.command(0x0) # no offset
341 | self.command(SSD1306_SETSTARTLINE | 0x0) # line #0
342 | self.command(SSD1306_CHARGEPUMP) # 0x8D
343 | if self._vccstate == SSD1306_EXTERNALVCC:
344 | self.command(0x10)
345 | else:
346 | self.command(0x14)
347 | self.command(SSD1306_MEMORYMODE) # 0x20
348 | self.command(0x00) # 0x0 act like ks0108
349 | self.command(SSD1306_SEGREMAP | 0x1)
350 | self.command(SSD1306_COMSCANDEC)
351 | self.command(SSD1306_SETCOMPINS) # 0xDA
352 | self.command(0x02)
353 | self.command(SSD1306_SETCONTRAST) # 0x81
354 | self.command(0x8F)
355 | self.command(SSD1306_SETPRECHARGE) # 0xd9
356 | if self._vccstate == SSD1306_EXTERNALVCC:
357 | self.command(0x22)
358 | else:
359 | self.command(0xF1)
360 | self.command(SSD1306_SETVCOMDETECT) # 0xDB
361 | self.command(0x40)
362 | self.command(SSD1306_DISPLAYALLON_RESUME) # 0xA4
363 | self.command(SSD1306_NORMALDISPLAY) # 0xA6
364 |
--------------------------------------------------------------------------------
/build/lib/NBX_OLED/__init__.py:
--------------------------------------------------------------------------------
1 | from .OLED import *
2 |
--------------------------------------------------------------------------------
/dist/Nabaixin_TFOLED-1.0.2-py3-none-any.whl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Nabaixin/TFOLED/e1ef018fda23f49469786d31bd86c03e04537e32/dist/Nabaixin_TFOLED-1.0.2-py3-none-any.whl
--------------------------------------------------------------------------------
/image-VWM8FnE.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Nabaixin/TFOLED/e1ef018fda23f49469786d31bd86c03e04537e32/image-VWM8FnE.png
--------------------------------------------------------------------------------
/image-ZyiqR6s.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Nabaixin/TFOLED/e1ef018fda23f49469786d31bd86c03e04537e32/image-ZyiqR6s.png
--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
1 | import os
2 | import io
3 | from setuptools import setup, find_packages
4 |
5 | here = os.path.abspath(os.path.dirname(__file__))
6 |
7 | # Import the README and use it as the long-description.
8 | with io.open(os.path.join(here, 'README.md'), encoding='utf-8') as f:
9 | long_description = '\n' + f.read()
10 |
11 | classifiers = ['Development Status :: 4 - Beta',
12 | 'Operating System :: POSIX :: Linux',
13 | 'License :: OSI Approved :: MIT License',
14 | 'Intended Audience :: Developers',
15 | 'Programming Language :: Python :: 2.7',
16 | 'Programming Language :: Python :: 3.7',
17 | 'Topic :: Software Development',
18 | 'Topic :: System :: Hardware']
19 |
20 | setup(name = 'Nabaixin_TFOLED',
21 | version = '1.0.2',
22 | author = 'Nabaixin.com',
23 | author_email = 'nabaixin@163.com',
24 | description = 'Python library to use RTC Fan OLED board for a Raspberry Pi or Beaglebone Black.',
25 | long_description = long_description,
26 | license = 'MIT',
27 | classifiers = classifiers,
28 | url = 'https://github.com/nabaixin/TFOLED/',
29 | dependency_links = ['https://github.com/adafruit/Adafruit_Python_GPIO/tarball/master#egg=Adafruit-GPIO-0.6.5'],
30 | install_requires = ['Adafruit-GPIO>=0.6.5'],
31 | packages = find_packages())
32 |
--------------------------------------------------------------------------------
/tool/SSH:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/tool/wpa_supplicant.conf:
--------------------------------------------------------------------------------
1 | ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
2 | update_config=1
3 | country=CN
4 |
5 | network={
6 | ssid="yourSSID"
7 | psk="YourPassword"
8 | key_mgmt=WPA-PSK
9 | }
10 |
--------------------------------------------------------------------------------