Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use object based interface in more examples
- Loading branch information
ponty
committed
Feb 27, 2014
1 parent
647504a
commit 36ab8c8
Showing
4 changed files
with
24 additions
and
14 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,31 @@ | ||
#!/usr/bin/env python | ||
|
||
# Author: Kevin Ng | ||
# Author: Kevin Ng | ||
# Description: read from EEPROM | ||
# Dependencies: None | ||
|
||
from nanpy import EEPROM | ||
from nanpy import (EepromLib, SerialManager) | ||
import sys | ||
|
||
EEPROM_SIZE = EEPROM.size() | ||
connection = SerialManager() | ||
e = EepromLib(connection=connection) | ||
|
||
|
||
def display(a_list): | ||
for i in range(0, EEPROM_SIZE//16-1): | ||
for i in range(0, e.size // 16 - 1): | ||
for j in range(16): | ||
sys.stdout.write("%02x:" % a_list[j + i * 16]) | ||
|
||
|
||
def read_eeprom(): | ||
data_list = [] | ||
for i in range(0, EEPROM_SIZE): | ||
s = EEPROM.read(i) | ||
for i in range(0, e.size): | ||
s = e.read(i) | ||
data_list.append(s) | ||
return data_list | ||
|
||
|
||
if __name__ == "__main__": | ||
print("Reading eeprom (%s bytes)..." % EEPROM_SIZE) | ||
print("Reading eeprom (%s bytes)..." % e.size) | ||
display(read_eeprom()) |