Ingo Hoffmann
Published © GPL3+

Graustufen OLED ansteuern auch ohne PXT Package

Das quadratische 1,12" OLED Display von Seeed kann 16 Graustufen darstellen. So zeigt man Texte und Werte an, inkl. deutscher Sonderzeichen.

AdvancedProtip2 hours1,178
Graustufen OLED ansteuern auch ohne PXT Package

Things used in this project

Hardware components

Calliope mini
Calliope mini
×1
Seeed Studio SeedStudio - Grove - OLED Display 1.12"
×1

Story

Read more

Custom parts and enclosures

Apple Numbers Tabelle

Zellen mit einer 1 füllen oder löschen. Formel addiert die Bitwerte.

Schematics

Block-Editor Ansicht der Funktionen

Ansicht im PXT Block-Editor

Code

Calliope Sensorwerte auf Graustufen OLED ausgeben

JavaScript
Einfach kopieren und in den PXT Editor unter JavaScript einfügen
let BeschleunigungX = 0
let BeschleunigungY = 0
let BeschleunigungZ = 0
let BeschleunigungStärke = 0
let MagnetkraftX = 0
let MagnetkraftY = 0
let MagnetkraftZ = 0
let MagnetkraftStärke = 0
let RotationWinkel = 0
let RotationRollen = 0
let Temperatur = 0
let Lichtstärke = 0
let Mikrofon = 0
let Kompassausrichtung = 0
let Laufzeit = 0
let grayLevel = 0
let currentDisplayIsInverted = false
let currentDisplayPageIsA = false
let currentDisplayModeIsVertical = false
basic.forever(() => {
    BeschleunigungX = input.acceleration(Dimension.X)
    BeschleunigungY = input.acceleration(Dimension.Y)
    BeschleunigungZ = input.acceleration(Dimension.Z)
    BeschleunigungStärke = input.acceleration(Dimension.Strength)
    MagnetkraftX = input.magneticForce(Dimension.X)
    MagnetkraftY = input.magneticForce(Dimension.Y)
    MagnetkraftZ = input.magneticForce(Dimension.Z)
    MagnetkraftStärke = input.magneticForce(Dimension.Strength)
    RotationWinkel = input.rotation(Rotation.Pitch)
    RotationRollen = input.rotation(Rotation.Roll)
    Temperatur = input.temperature()
    Mikrofon = pins.analogReadPin(AnalogPin.MIC)
    Lichtstärke = input.lightLevel()
    Kompassausrichtung = input.compassHeading()
    Laufzeit = input.runningTime()
    if (currentDisplayPageIsA) {
        drawPageA()
    } else {
        drawPageB()
    }
})
input.onButtonPressed(Button.A, () => {
    if (currentDisplayIsInverted) {
        setNormalDisplay()
    } else {
        setInverseDisplay()
    }
})
input.onButtonPressed(Button.B, () => {
    if (currentDisplayPageIsA) {
        currentDisplayPageIsA = false
        initPageB()
    } else {
        currentDisplayPageIsA = true
        initPageA()
    }
})
let basicFont: int8[] =[
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // " "
    0x00, 0x00, 0x5F, 0x00, 0x00, 0x00, 0x00, 0x00, // "!"
    0x00, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, // """
    0x00, 0x14, 0x7F, 0x14, 0x7F, 0x14, 0x00, 0x00, // "#"
    0x00, 0x24, 0x2A, 0x7F, 0x2A, 0x12, 0x00, 0x00, // "$"
    0x00, 0x23, 0x13, 0x08, 0x64, 0x62, 0x00, 0x00, // "%"
    0x00, 0x36, 0x49, 0x55, 0x22, 0x50, 0x00, 0x00, // "&"
    0x00, 0x00, 0x05, 0x03, 0x00, 0x00, 0x00, 0x00, // "'"
    0x00, 0x1C, 0x22, 0x41, 0x00, 0x00, 0x00, 0x00, // "("
    0x00, 0x41, 0x22, 0x1C, 0x00, 0x00, 0x00, 0x00, // ")"
    0x00, 0x08, 0x2A, 0x1C, 0x2A, 0x08, 0x00, 0x00, // "*"
    0x00, 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00, 0x00, // "+"
    0x00, 0xA0, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, // ","
    0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, // "-"
    0x00, 0x60, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, // "."
    0x00, 0x20, 0x10, 0x08, 0x04, 0x02, 0x00, 0x00, // "/"
    0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E, 0x00, 0x00, // "0"
    0x00, 0x00, 0x42, 0x7F, 0x40, 0x00, 0x00, 0x00, // "1"
    0x00, 0x62, 0x51, 0x49, 0x49, 0x46, 0x00, 0x00, // "2"
    0x00, 0x22, 0x41, 0x49, 0x49, 0x36, 0x00, 0x00, // "3"
    0x00, 0x18, 0x14, 0x12, 0x7F, 0x10, 0x00, 0x00, // "4"
    0x00, 0x27, 0x45, 0x45, 0x45, 0x39, 0x00, 0x00, // "5"
    0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30, 0x00, 0x00, // "6"
    0x00, 0x01, 0x71, 0x09, 0x05, 0x03, 0x00, 0x00, // "7"
    0x00, 0x36, 0x49, 0x49, 0x49, 0x36, 0x00, 0x00, // "8"
    0x00, 0x06, 0x49, 0x49, 0x29, 0x1E, 0x00, 0x00, // "9"
    0x00, 0x00, 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, // ":"
    0x00, 0x00, 0xAC, 0x6C, 0x00, 0x00, 0x00, 0x00, // ";"
    0x00, 0x08, 0x14, 0x22, 0x41, 0x00, 0x00, 0x00, // "<"
    0x00, 0x14, 0x14, 0x14, 0x14, 0x14, 0x00, 0x00, // "="
    0x00, 0x41, 0x22, 0x14, 0x08, 0x00, 0x00, 0x00, // ">"
    0x00, 0x02, 0x01, 0x51, 0x09, 0x06, 0x00, 0x00, // "?"
    0x00, 0x32, 0x49, 0x79, 0x41, 0x3E, 0x00, 0x00, // "@"
    0x00, 0x7E, 0x09, 0x09, 0x09, 0x7E, 0x00, 0x00, // "A"
    0x00, 0x7F, 0x49, 0x49, 0x49, 0x36, 0x00, 0x00, // "B"
    0x00, 0x3E, 0x41, 0x41, 0x41, 0x22, 0x00, 0x00, // "C"
    0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C, 0x00, 0x00, // "D"
    0x00, 0x7F, 0x49, 0x49, 0x49, 0x41, 0x00, 0x00, // "E"
    0x00, 0x7F, 0x09, 0x09, 0x09, 0x01, 0x00, 0x00, // "F"
    0x00, 0x3E, 0x41, 0x41, 0x51, 0x72, 0x00, 0x00, // "G"
    0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00, 0x00, // "H"
    0x00, 0x41, 0x7F, 0x41, 0x00, 0x00, 0x00, 0x00, // "I"
    0x00, 0x20, 0x40, 0x41, 0x3F, 0x01, 0x00, 0x00, // "J"
    0x00, 0x7F, 0x08, 0x14, 0x22, 0x41, 0x00, 0x00, // "K"
    0x00, 0x7F, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00, // "L"
    0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F, 0x00, 0x00, // "M"
    0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F, 0x00, 0x00, // "N"
    0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E, 0x00, 0x00, // "O"
    0x00, 0x7F, 0x09, 0x09, 0x09, 0x06, 0x00, 0x00, // "P"
    0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E, 0x00, 0x00, // "Q"
    0x00, 0x7F, 0x09, 0x19, 0x29, 0x46, 0x00, 0x00, // "R"
    0x00, 0x26, 0x49, 0x49, 0x49, 0x32, 0x00, 0x00, // "S"
    0x00, 0x01, 0x01, 0x7F, 0x01, 0x01, 0x00, 0x00, // "T"
    0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F, 0x00, 0x00, // "U"
    0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F, 0x00, 0x00, // "V"
    0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F, 0x00, 0x00, // "W"
    0x00, 0x63, 0x14, 0x08, 0x14, 0x63, 0x00, 0x00, // "X"
    0x00, 0x03, 0x04, 0x78, 0x04, 0x03, 0x00, 0x00, // "Y"
    0x00, 0x61, 0x51, 0x49, 0x45, 0x43, 0x00, 0x00, // "Z"
    0x00, 0x7F, 0x41, 0x41, 0x00, 0x00, 0x00, 0x00, // "["
    0x00, 0x02, 0x04, 0x08, 0x10, 0x20, 0x00, 0x00, // "\"
    0x00, 0x41, 0x41, 0x7F, 0x00, 0x00, 0x00, 0x00, // "]"
    0x00, 0x04, 0x02, 0x01, 0x02, 0x04, 0x00, 0x00, // "^"
    0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, // "_"
    0x00, 0x01, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, // "`"
    0x00, 0x20, 0x54, 0x54, 0x54, 0x78, 0x00, 0x00, // "a"
    0x00, 0x7F, 0x48, 0x44, 0x44, 0x38, 0x00, 0x00, // "b"
    0x00, 0x38, 0x44, 0x44, 0x28, 0x00, 0x00, 0x00, // "c"
    0x00, 0x38, 0x44, 0x44, 0x48, 0x7F, 0x00, 0x00, // "d"
    0x00, 0x38, 0x54, 0x54, 0x54, 0x18, 0x00, 0x00, // "e"
    0x00, 0x08, 0x7E, 0x09, 0x02, 0x00, 0x00, 0x00, // "f"
    0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C, 0x00, 0x00, // "g"
    0x00, 0x7F, 0x08, 0x04, 0x04, 0x78, 0x00, 0x00, // "h"
    0x00, 0x00, 0x7D, 0x00, 0x00, 0x00, 0x00, 0x00, // "i"
    0x00, 0x80, 0x84, 0x7D, 0x00, 0x00, 0x00, 0x00, // "j"
    0x00, 0x7F, 0x10, 0x28, 0x44, 0x00, 0x00, 0x00, // "k"
    0x00, 0x41, 0x7F, 0x40, 0x00, 0x00, 0x00, 0x00, // "l"
    0x00, 0x7C, 0x04, 0x18, 0x04, 0x78, 0x00, 0x00, // "m"
    0x00, 0x7C, 0x08, 0x04, 0x7C, 0x00, 0x00, 0x00, // "n"
    0x00, 0x38, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00, // "o"
    0x00, 0xFC, 0x24, 0x24, 0x18, 0x00, 0x00, 0x00, // "p"
    0x00, 0x18, 0x24, 0x24, 0xFC, 0x00, 0x00, 0x00, // "q"
    0x00, 0x00, 0x7C, 0x08, 0x04, 0x00, 0x00, 0x00, // "r"
    0x00, 0x48, 0x54, 0x54, 0x24, 0x00, 0x00, 0x00, // "s"
    0x00, 0x04, 0x7F, 0x44, 0x00, 0x00, 0x00, 0x00, // "t"
    0x00, 0x3C, 0x40, 0x40, 0x7C, 0x00, 0x00, 0x00, // "u"
    0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C, 0x00, 0x00, // "v"
    0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C, 0x00, 0x00, // "w"
    0x00, 0x44, 0x28, 0x10, 0x28, 0x44, 0x00, 0x00, // "x"
    0x00, 0x1C, 0xA0, 0xA0, 0x7C, 0x00, 0x00, 0x00, // "y"
    0x00, 0x44, 0x64, 0x54, 0x4C, 0x44, 0x00, 0x00, // "z"
    0x00, 0x08, 0x36, 0x41, 0x00, 0x00, 0x00, 0x00, // "{"
    0x00, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, // "|"
    0x00, 0x41, 0x36, 0x08, 0x00, 0x00, 0x00, 0x00, // "}"
    0x00, 0x02, 0x01, 0x01, 0x02, 0x01, 0x00, 0x00 // "~"
]
let extendedCharacters: int8[] =[
    0x00, 0x7D, 0x0A, 0x09, 0x0A, 0x7D, 0x00, 0x00, // "Ä"
    0x00, 0x3D, 0x42, 0x41, 0x42, 0x3D, 0x00, 0x00, // "Ö"
    0x00, 0x3D, 0x40, 0x40, 0x40, 0x3D, 0x00, 0x00, // "Ü"
    0x00, 0x21, 0x54, 0x54, 0x55, 0x78, 0x00, 0x00, // "ä"
    0x00, 0x39, 0x44, 0x44, 0x39, 0x00, 0x00, 0x00, // "ö"
    0x00, 0x3D, 0x40, 0x40, 0x7D, 0x00, 0x00, 0x00, // "ü"
    0x00, 0xFE, 0x09, 0x49, 0x36, 0x00, 0x00, 0x00, // "ß"
    0x00, 0x14, 0x3E, 0x55, 0x55, 0x55, 0x14, 0x00, // ""
    0x00, 0x02, 0x05, 0x02, 0x00, 0x00, 0x00, 0x00, // "°"
    0x00, 0x0A, 0x55, 0x55, 0x55, 0x28, 0x00, 0x00 // "§"
]
currentDisplayModeIsVertical = false
currentDisplayPageIsA = false
grayLevel = 15
init()
setVerticalMode()
setNormalDisplay()
deactivateScroll()
initPageB()
function init() {
    pins.i2cWriteNumber(0x3c, 0x80fd, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x8012, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x80ae, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x80a8, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x805f, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x80a1, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x8000, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x80a2, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x8060, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x80ab, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x8001, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x8081, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x8053, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x80b1, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x8051, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x80b3, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x8001, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x80b9, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x80bc, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x8008, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x80be, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x8007, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x80b6, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x8001, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x80d5, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x8062, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x80af, NumberFormat.UInt16BE)
    control.waitMicros(100)
    pins.i2cWriteNumber(0x3c, 0x8075, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x8000, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x805f, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x8015, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x8008, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x8037, NumberFormat.UInt16BE)
}
function clearDisplay() {
    let previousOrientation = currentDisplayModeIsVertical
    setHorizontalMode()
    for (let j = 0; j <= 47; j++) {
        for (let i = 0; i <= 95; i++) {
            pins.i2cWriteNumber(0x3c, 0x4000, NumberFormat.UInt16BE)
        }
    }
    if (previousOrientation) {
        setVerticalMode()
    }
}
function setContrastLevel(contrastLevel: number) {
    pins.i2cWriteNumber(0x3c, 0x8081, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x8000 + contrastLevel, NumberFormat.UInt16BE)
}
function setHorizontalMode() {
    pins.i2cWriteNumber(0x3c, 0x80a0, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x8042, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x8075, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x8000, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x805f, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x8015, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x8008, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x8037, NumberFormat.UInt16BE)
    currentDisplayModeIsVertical = false
}
function setVerticalMode() {
    pins.i2cWriteNumber(0x3c, 0x80a0, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x8046, NumberFormat.UInt16BE)
    currentDisplayModeIsVertical = true
}
function setGrayLevel(newLevel: number) {
    grayLevel = newLevel
}
function setTextXY(row: number, column: number) {
    pins.i2cWriteNumber(0x3c, 0x8015, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x8008 + (column * 4), NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x8037, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x8075, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x8000 + (row * 8), NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x8007 + (row * 8), NumberFormat.UInt16BE)
}
function putChar(theChar: string) {
    let standardCharacter = true
    let charBaseIndex = 0
    if (theChar.charCodeAt(0) == 196) {
        charBaseIndex = 0 * 8
        standardCharacter = false
    }
    if (theChar.charCodeAt(0) == 214) {
        charBaseIndex = 1 * 8
        standardCharacter = false
    }
    if (theChar.charCodeAt(0) == 220) {
        charBaseIndex = 2 * 8
        standardCharacter = false
    }
    if (theChar.charCodeAt(0) == 228) {
        charBaseIndex = 3 * 8
        standardCharacter = false
    }
    if (theChar.charCodeAt(0) == 246) {
        charBaseIndex = 4 * 8
        standardCharacter = false
    }
    if (theChar.charCodeAt(0) == 252) {
        charBaseIndex = 5 * 8
        standardCharacter = false
    }
    if (theChar.charCodeAt(0) == 223) {
        charBaseIndex = 6 * 8
        standardCharacter = false
    }
    if (theChar.charCodeAt(0) == 172) {
        charBaseIndex = 7 * 8
        standardCharacter = false
    }
    if (theChar.charCodeAt(0) == 176) {
        charBaseIndex = 8 * 8
        standardCharacter = false
    }
    if (theChar.charCodeAt(0) == 167) {
        charBaseIndex = 9 * 8
        standardCharacter = false
    }
    if (standardCharacter) {
        if (theChar.charCodeAt(0) < 32 || theChar.charCodeAt(0) > 126) {
            theChar = " "
        }
        charBaseIndex = (theChar.charCodeAt(0) - 32) * 8
    }
    let charColumn1 = 0
    let charColumn2 = 0
    for (let m = 0; m <= 3; m++) {
        if (standardCharacter) {
            charColumn1 = basicFont[charBaseIndex + (m * 2)]
            charColumn2 = basicFont[charBaseIndex + (m * 2) + 1]
        } else {
            charColumn1 = extendedCharacters[charBaseIndex + (m * 2)]
            charColumn2 = extendedCharacters[charBaseIndex + (m * 2) + 1]
        }
        for (let n = 0; n <= 7; n++) {
            let pixel1 = charColumn1 % 2
            let pixel2 = charColumn2 % 2
            let data = (pixel1 * 16 * grayLevel) + (pixel2 * grayLevel)
            pins.i2cWriteNumber(0x3c, 0x4000 + data, NumberFormat.UInt16BE)
            charColumn1 = charColumn1 / 2
            charColumn2 = charColumn2 / 2
        }
    }
}
function putString(theString: string) {
    for (let p = 0; p <= theString.length - 1; p++) {
        putChar(theString.substr(p, 1))
    }
}
function putNumber(theNumber: number, chars: number) {
    let r: number = 0
    let numberLength = theNumber.toString().length
    if (numberLength < chars) {
        for (r = 0; r < (chars - numberLength); r++) {
            putChar(" ")
        }
        putString(theNumber.toString())
    } else if (numberLength > chars) {
        for (r = 0; r < chars; r++) {
            putChar("*")
        }
    } else {
        putString(theNumber.toString())
    }
}
function setHorizontalScrollProperties(scrollRight: boolean, startRow: number, endRow: number, startColumn: number, endColumn: number, scrollSpeed: number) {
    if (scrollRight) {
        pins.i2cWriteNumber(0x3c, 0x8027, NumberFormat.UInt16BE)
    } else {
        pins.i2cWriteNumber(0x3c, 0x8026, NumberFormat.UInt16BE)
    }
    pins.i2cWriteNumber(0x3c, 0x8000, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x8000 + startRow, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x8000 + scrollSpeed, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x8000 + endRow, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x8000 + startColumn + 8, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x8000 + endColumn + 8, NumberFormat.UInt16BE)
    pins.i2cWriteNumber(0x3c, 0x8000, NumberFormat.UInt16BE)
}
function activateScroll() {
    pins.i2cWriteNumber(0x3c, 0x802f, NumberFormat.UInt16BE)
}
function deactivateScroll() {
    pins.i2cWriteNumber(0x3c, 0x802e, NumberFormat.UInt16BE)
}
function setNormalDisplay() {
    pins.i2cWriteNumber(0x3c, 0x80a4, NumberFormat.UInt16BE)
    currentDisplayIsInverted = false
}
function setInverseDisplay() {
    pins.i2cWriteNumber(0x3c, 0x80a7, NumberFormat.UInt16BE)
    currentDisplayIsInverted = true
}
function drawPageA() {
    setTextXY(1, 1)
    putNumber(BeschleunigungX, 5)
    setTextXY(1, 7)
    putNumber(BeschleunigungY, 5)
    setTextXY(2, 1)
    putNumber(BeschleunigungZ, 5)
    setTextXY(2, 7)
    putNumber(BeschleunigungStärke, 5)
    setTextXY(4, 1)
    putNumber(MagnetkraftX, 5)
    setTextXY(4, 7)
    putNumber(MagnetkraftY, 5)
    setTextXY(5, 1)
    putNumber(MagnetkraftZ, 5)
    setTextXY(5, 7)
    putNumber(MagnetkraftStärke, 5)
    setTextXY(7, 1)
    putNumber(RotationWinkel, 5)
    setTextXY(7, 7)
    putNumber(RotationRollen, 5)
    setTextXY(9, 0)
    putNumber(Lichtstärke, 4)
    setTextXY(9, 4)
    putNumber(Temperatur, 4)
    setTextXY(9, 8)
    putNumber(Mikrofon, 4)
    setTextXY(10, 4)
    putNumber(Kompassausrichtung, 5)
    setTextXY(11, 4)
    putNumber(Laufzeit, 8)
}
function drawPageB() {

}
function initPageA() {
    clearDisplay()
    setGrayLevel(1)
    setTextXY(0, 0)
    putString("Beschleunig.")
    setTextXY(3, 0)
    putString("Magnetkraft")
    setTextXY(6, 0)
    putString("Rotation")
    setTextXY(8, 0)
    putString("Li.")
    setTextXY(8, 4)
    putString("Te.")
    setTextXY(8, 8)
    putString("Mi.")
    setTextXY(10, 0)
    putString("Komp")
    setTextXY(11, 0)
    putString("Zeit")
    setGrayLevel(5)
    setTextXY(1, 0)
    putString("X")
    setTextXY(1, 6)
    putString("Y")
    setTextXY(2, 0)
    putString("Z")
    setTextXY(2, 6)
    putString("S")
    setTextXY(4, 0)
    putString("X")
    setTextXY(4, 6)
    putString("Y")
    setTextXY(5, 0)
    putString("Z")
    setTextXY(5, 6)
    putString("S")
    setTextXY(7, 0)
    putString("W")
    setTextXY(7, 6)
    putString("R")
    setGrayLevel(15)
}
function initPageB() {
    clearDisplay()
    setGrayLevel(10)
    setTextXY(5, 0)
    putString("ÄÖÜäöü߀°§")
    setTextXY(6, 2)
    putNumber(1234, 6)
}

Credits

Ingo Hoffmann

Ingo Hoffmann

1 project • 6 followers
Maker, Udemy Instructor
Thanks to HHF.

Comments