Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jxns committed Aug 24, 2023
1 parent d83b5a6 commit 7a36ea1
Show file tree
Hide file tree
Showing 12 changed files with 8,315 additions and 2 deletions.
33 changes: 33 additions & 0 deletions COM-EEPROM-32.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//% color="#275C6B" weight=100 icon="\uf2db" block="COM-EEPROM-32"
namespace COMEEPROM32 {
let eepromADDR = 0x50;

/**
* Writes data to the EEPROM storage
* @param data The data that is supposed to be written
* @param address The address of the EEPROM where the data is supposed to be stored
*/
//% block="write %dat to EEPROM address %addr"
//% weight=100
export function eepromWrite(data: number, address: number): void {
let buf = pins.createBuffer(3);

buf[0] = address >> 8;
buf[1] = (address & 0xFF);
buf[2] = data;
pins.i2cWriteBuffer(eepromADDR, buf)
}

/**
* Reads data from the EEPROM storage
* @param address The address of the EEPROM where the data is supposed to be read from
*/
//% block="read byte from EEPROM address %addr"
//% weight=99
export function eepromRead(address: number): number {
pins.i2cWriteNumber(eepromADDR, address, NumberFormat.UInt16BE);
return pins.i2cReadNumber(eepromADDR, NumberFormat.UInt8BE);
}


}
38 changes: 36 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,36 @@
# pxt-COM-EEPROM-32
This library provides a Microsoft Makecode package for the Joy-IT COM-EEPROM-32
# MakeCode Package for the Joy-IT COM-EEPROM-32

This library provides a Microsoft Makecode package for the Joy-IT COM-EEPROM-32. See https://joy-it.net/products/COM-EEPROM-32 for more details.

## Overview

This EEPROM memory allows you to store and read data externally via the I2C interface of your microcontroller.

## Connection

| COM-EEPROM-32 | Micro:Bit |
|:------------------------:|:----------------------------------:|
| VCC | 3,3 V |
| SCL | P19 (SCL) |
| SDA | P20 (SDA) |
| GND | GND |

## Example

### Write data

You can write up to 32 kB of data to the EEPROM by using the **COMEEPROM32.eepromWrite(data, address)** function. Both parameters, **data** and **address**, need to be a number.

```typescript
// Write number 12345 to address 5
COMEEPROM32.eepromWrite(12345, 5);
```

### Read data

Data can be read out by using the **COMEEPROM32.eepromRead(address)** function.

```typescript
// Read data from address 5
COMEEPROM32.eepromRead(5)
```
7 changes: 7 additions & 0 deletions _locales/de/pxt-com-eeprom-32-jsdoc-strings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"COMEEPROM32.eepromRead": "Liest Daten aus dem EEPROM-Speicher",
"COMEEPROM32.eepromRead|param|address": "Die Adresse des EEPROM, aus dem die Daten gelesen werden sollen",
"COMEEPROM32.eepromWrite": "Schreibt Daten in den EEPROM-Speicher",
"COMEEPROM32.eepromWrite|param|address": "Die Adresse des EEPROM, in dem die Daten gespeichert werden sollen",
"COMEEPROM32.eepromWrite|param|data": "Die Daten, die geschrieben werden sollen"
}
6 changes: 6 additions & 0 deletions _locales/de/pxt-com-eeprom-32-strings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"COMEEPROM32.eepromRead|block": "Byte von EEPROM-Adresse %addr lesen",
"COMEEPROM32.eepromWrite|block": "Schreiben von %dat in EEPROM-Adresse %addr",
"COMEEPROM32|block": "COM-EEPROM-32",
"{id:category}COMEEPROM32": "COM-EEPROM-32"
}
7 changes: 7 additions & 0 deletions _locales/en/pxt-com-eeprom-32-jsdoc-strings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"COMEEPROM32.eepromRead": "Reads data from the EEPROM storage",
"COMEEPROM32.eepromRead|param|address": "The address of the EEPROM where the data is supposed to be read from",
"COMEEPROM32.eepromWrite": "Writes data to the EEPROM storage",
"COMEEPROM32.eepromWrite|param|address": "The address of the EEPROM where the data is supposed to be stored",
"COMEEPROM32.eepromWrite|param|data": "The data that is supposed to be written"
}
6 changes: 6 additions & 0 deletions _locales/en/pxt-com-eeprom-32-strings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"COMEEPROM32.eepromRead|block": "read byte from EEPROM address %addr",
"COMEEPROM32.eepromWrite|block": "write %dat to EEPROM address %addr",
"COMEEPROM32|block": "COM-EEPROM-32",
"{id:category}COMEEPROM32": "COM-EEPROM-32"
}
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 7a36ea1

Please sign in to comment.