adafruit / Adafruit_CircuitPython_24LC32

CircuitPython Driver for Adafruit 24LC32 I2C EEPROM Breakout 32Kbit / 4 KB
MIT License
6 stars 6 forks source link

Stores wrong value for 9, 10, 13 #7

Open b-blake opened 2 years ago

b-blake commented 2 years ago

For some reason the library is converting the 9, 10, 13 to TAB, NEW_LINE, CARRAGE_RETURN and storing the "\" character, 0x53, into the EEPROM.

eeprom[0x10] = 9 print(eeprom[0x10]) eeprom[0x10:0x16] = [9, 10, 13, 3, 8, 1] print(eeprom[0x10:0x18])

EEPROM Dump: 0x0010 | 0x5C 0x03 0x08 0x01 0xFF 0xFF 0xFF 0xFF

The output shows: bytearray(b'\t') bytearray(b'\t\n\r\x03\x08\x01\xff\xff')

How do I get an output "stuff=eeprom(0x10:0x18)" other than in a bytearray?

Bruce

dhalbert commented 2 years ago

\x09 is exactly the same bits as \t, and similarly for the other characters. It's just that when it can interpret a byte as a character, it prints that character, rather than \xnn.

b-blake commented 2 years ago

My mistake: Forget all after Hello.

b-blake commented 2 years ago

Dan,

I know "Consistency is the bane of a narrow mind."

If \t, \n, \r are shown in bytearray, shouldn't \b and \f also be shown?

\b aka Back_Space aka 0x08 is recognized in print("\b") and the cursor moves back one space. \f aka Form_Feed aka Clear_Screen aka 0x0C is recognized in print("\f") and the REPL screen is cleared.

Bruce

tekktrik commented 2 years ago

@dhalbert thoughts on this? I'm going through issues and saw this, and I'm pretty sure it's specific to the core and not this repo.