예제 #1
0
def initaddon(name, driver_name, data=b''):
    eeprom = EEPROM(badge.i2c)
    addons.write_addon_descriptor(eeprom, {
        "name": name,
        "driver": driver_name,
        "data": data,
    })
    return addons.read_addon_descriptor(eeprom)
예제 #2
0
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU Lesser General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

import sys, cpu, string, avr, math
from tmp36 import TMP36
from eeprom import EEPROM
from time import Time
from device import Device
from sram import SRAM

__name__ = "__main__"

ee = EEPROM("24C02")
ram = SRAM("23K256")
addr = 0x60
data_ary = [155.0, 121.3, 3.1415, 12.2, 90.0, 8.91]
ram_lst = [3.1415, 12.1, math.pi]


def print_temperature(sensor):
    tm = Time(True)
    high = False
    while True:
        temp = sensor.read()
        tm.now()
        print "[python]:    Temperature: %f at %s" % (temp, tm.to_string())

        if high:
예제 #3
0
def get_eep():
    if uos.uname().machine.split(' ')[0][:4] == 'PYBD':
        Pin.board.EN_3V3.value(1)
    eep = EEPROM(I2C(2), T24C512)
    print('Instantiated EEPROM')
    return eep
예제 #4
0
            return addr in i2c.scan()
        finally:
            i2c.unlock()

def main_screen():
    badge.display.push_mode(badge.display.MODE_QUICK)
    try:
        badge.show_bitmap('nametag.bmp')
    except:
        show_welcome()
    while badge.display.time_to_refresh > 0:
        pass
    badge.display.refresh()
    badge.display.pop_mode()

e = EEPROM(badge.i2c)
menu = MenuApp()

main_screen()

last_addon = None
badge.vibration = False
badge.pixels.fill(0)
while True:
    buttons = badge.gamepad.get_pressed()
    if buttons:
        # Wait until the action button is released
        badge.vibration = True
        while badge.gamepad.get_pressed():
            pass
        badge.vibration = False
예제 #5
0

def change_name(obj, name):
    """__NATIVE__
	pPmObj_t obj, name;

	obj = NATIVE_GET_LOCAL(0);
	name = NATIVE_GET_LOCAL(1);

	return class_set_attr_cstr(obj, \"name\", name);
	"""
    pass


ram = SRAM("23K256")
ee = EEPROM("24C02")
aobj = A()

data_ary = [100.1, 50.2, 33.3]
data_len = len(data_ary)
sram_str = "Some piece of text"
sram_len = len(sram_str)

ram.write_string(0x40, sram_str)
ee.write_list(data_ary, True, 0x10)

change_name(aobj, "Hello, World")
print aobj.name
print math.atan2(1, 0)

readback = ee.read_list(data_len, True, 0x10)
예제 #6
0
from eeprom import EEPROM

eeprom = EEPROM("24c64", 0, 0x54)

test_string = "This is a string of test data."
test_length = len(test_string)

eeprom.write(test_string.encode())
verify = eeprom.read(test_length).decode()

print(verify)

assert verify == test_string
예제 #7
0
def mountfloppy():
    e = EEPROM(badge.i2c)
    addon = addons.read_addon_descriptor(e)
    eeprom = create_eeprom(addon)
    fs = mount_eeprom(eeprom, "/floppy")
    return fs
예제 #8
0
def create_eeprom(addon):
    eeprom_addr, eeprom_size, page_size = read_config(addon)
    return EEPROM(badge.i2c, eeprom_addr=eeprom_addr, eeprom_size=eeprom_size, page_size=page_size)