Speicher Limit erreicht?

Hallo. Wir haben mit Hilfe von Claude 3.5 ein kleines „Fußball-Orakel“ für den Calliope 2 Mini erstellt. Siehe unten.
Das Programm läuft, wenn wir nur maximal 20 Spielergebnisse reinladen. Bei einer größeren Anzahl von Spielen, funktioniert das Programm zwar immernoch im Test im Browser (Desktop) oder auf dem iPad, auf dem Calliope flackert aber nur noch die LEDs kurz auf.
Kann mir jemand sagen, ob wir hier wirklich an das Speicherlimit kommen? Und wenn ja, dann würde mich interessieren, ob das mit dem Calliope 3 anders wäre.

Eigentlich war das Ziel alle Spiele des DFB Pokals reinzuladen. Vielleicht sogar in doppelt mit vertauschter Heim- und Auswärtsmannschaft. Das wären dann 2x63 Spiele.

Schöne Grüße

===

Funktionierender Code auf Calliope Mini 2:

let results = ["2:1","0:7","3:3","1:3","0:4","0:5","1:6","0:5","3:2","0:2","0:8","1:9","0:1","2:2","0:1","0:8","3:4","0:2","0:5","0:7"]
let penalties = ["","","4:2","","","","","","","","","","","4:1","","","","","",""]
let currentIndex = -1

// Function to pick a random match and show result
function showRandomResult() {
    currentIndex = Math.randomRange(0, results.length - 1)
    basic.showString(results[currentIndex])
}

// Function to show penalty result
function showPenaltyResult() {
    if (currentIndex >= 0) {
        if (penalties[currentIndex] !== "") {
            basic.showString(penalties[currentIndex])
        } else {
            basic.showString(results[currentIndex])
        }
    }
}

// Display soccer ball at start
basic.showLeds(`
    . # . # .
    # . # . #
    . # # # .
    # . # . #
    . # . # .
`)
basic.pause(1000)
basic.clearScreen()

// Button A: Pick random match and show result
input.onButtonPressed(Button.A, function() {
    showRandomResult()
})

// Button B: Show penalty result if available
input.onButtonPressed(Button.B, function() {
    showPenaltyResult()
})

// Shake: Show random "A" or "H"
input.onGesture(Gesture.Shake, function() {
    if (Math.randomBoolean()) {
        basic.showString("A")
    } else {
        basic.showString("H")
    }
})

Fehlerhafter Code wäre:

let results = let results = ["2:1","0:7","3:3","1:3","0:4","0:5","1:6","0:5","3:2","0:2","0:8","1:9","0:1","2:2","0:1","0:8","3:4","0:2","0:5","0:7","1:3","0:6","2:0","1:1","0:4","0:7","0:3","1:4","1:2","1:3","0:4","2:3","2:1","2:1","1:0","1:0","1:1","3:6","3:1","3:2","2:5","3:3","1:3","1:0","0:2","2:1","3:2","3:0"]
let penalties = ["","","4:2","","","","","","","","","","","4:1","","","","","","","","","","0:3","","","","","","","","","","","","","3:4","","","","","3:4","","","","","",""]
let currentIndex = -1

[...]
1 „Gefällt mir“

Hallo David,

Habe keinen V2 da. Nur einen V1 und V3.

Code läuft

// Button A: Pick random match and show result

input.onButtonPressed(Button.A, function () {

showRandomResult()

})

// Function to pick a random match and show result

function showRandomResult () {

currentIndex = Math.randomRange(0, results.length - 1)

basic.showString(„“ + (results[currentIndex]))

}

// Shake: Show random „A“ or „H“

input.onGesture(Gesture.Shake, function () {

if (Math.randomBoolean()) {

basic.showString(„A“)

} else {

basic.showString(„H“)

}

})

// Button B: Show penalty result if available

input.onButtonPressed(Button.B, function () {

showPenaltyResult()

})

// Function to show penalty result

function showPenaltyResult () {

if (currentIndex >= 0) {

if (penalties[currentIndex] != „“) {

basic.showString(„“ + (penalties[currentIndex]))

} else {

basic.showString(„“ + (results[currentIndex]))

}

}

}

let currentIndex = 0

let penalties: string =

let results: string =

results = [

„2:1“,

„0:7“,

„3:3“,

„1:3“,

„0:4“,

„0:5“,

„1:6“,

„0:5“,

„3:2“,

„0:2“,

„0:8“,

„1:9“,

„0:1“,

„2:2“,

„0:1“,

„0:8“,

„3:4“,

„0:2“,

„0:5“,

„0:7“,

„1:3“,

„0:6“,

„2:0“,

„1:1“,

„0:4“,

„0:7“,

„0:3“,

„1:4“,

„1:2“,

„1:3“,

„0:4“,

„2:3“,

„2:1“,

„2:1“,

„1:0“,

„1:0“,

„1:1“,

„3:6“,

„3:1“,

„3:2“,

„2:5“,

„3:3“,

„1:3“,

„1:0“,

„0:2“,

„2:1“,

„3:2“,

„3:0“

]

penalties = [

„“,

„“,

„4:2“,

„“,

„“,

„“,

„“,

„“,

„“,

„“,

„“,

„“,

„“,

„4:1“,

„“,

„“,

„“,

„“,

„“,

„“,

„“,

„“,

„“,

„0:3“,

„“,

„“,

„“,

„“,

„“,

„“,

„“,

„“,

„“,

„“,

„“,

„“,

„3:4“,

„“,

„“,

„“,

„“,

„3:4“,

„“,

„“,

„“,

„“,

„“,

„“

]

currentIndex = -1

// Display soccer ball at start

basic.showLeds(`

. # . # .

. # .

. # # # .

. # .

. # . # .

`)

basic.pause(1000)

basic.clearScreen()

Vom Platz her passt es eigentlich.
Außer du hast die Bluetootherweiterung geladen.

2 „Gefällt mir“

Hey @klmi,
vielen Dank für deine Antwort.

Ich muss ein paar Fragen dazu stellen:
1/ Du konntest deinen Code auf dem Calliope 1 laufen lassen? Oder bezieht sich das auf den Calliope 3?

2/ Ich habe keine Veränderung an der standard Firmware vorgenommen. Und ich arbeite auch oft über Bluetooth. Also nehme ich an, ich nutze die Bluetootherweiterung. Kannst du mir sagen, wie ich das prüfen könnte?

3/ Netter Screenshot. Wie bekomme ich denn diese Übersicht?

Sorry, für die vielen Fragen.

Insgesamt glaube ich nicht, dass der Speicher des Calliope 2 überlastet ist. Ich habe mich eher gefragt, ob ich mit der Tabelle in ein Arbeitsspeicher oder Zwischenspeicher Problem laufe. Die Ursache scheint eindeutig. Bei 40 Spielen geht nichts. Bei 20 Spielen geht es. Irgendwo dazwischen liegt das Limit.

1 „Gefällt mir“

Vielleicht hilft das weiter:

Calliope 2 stürzt ab bei bestimmten Array und Buffer Größen - Software Fragen und Probleme / Fragen zu MakeCode/PXT - Calliope

2 „Gefällt mir“

Hallo @asp.net
vielen Dank. Das war genau der Hinweis, den ich benötigt habe. Da wäre ich nie darauf gekommen.

Wenn ich die Projekteinstellungen um

{
    "yotta": {
        "config": {
            "microbit-dal": {
                "bluetooth": {
                    "enabled": 0
                }
            }
        }
    }
}

erweitere, kann ich ohne Probleme alle 126 Spielergebnisse des DFB Pokals 2023/2024 auf den Calliope laden. Das sind 63 Spiele und dann noch einmal alle Ergebisse mit vertauschter Heim- und Auswärtsmannschaft.

Den kompletten Code ergänze ich unten.

Vielen Dank und schöne Grüße

===

let results = ["2:1","0:7","3:3","1:3","0:4","0:5","1:6","0:5","3:2","0:2","0:8","1:9","0:1","2:2","0:1","0:8","3:4","0:2","0:5","0:7","1:3","0:6","2:0","1:1","0:4","0:7","0:3","1:4","1:2","1:3","0:4","2:3","2:1","2:1","1:0","1:0","1:1","3:6","3:1","3:2","2:5","3:3","1:3","1:0","0:2","2:1","3:2","3:0","2:0","1:2","1:0","1:4","2:0","3:1","2:0","3:3","2:2","1:3","3:2","2:1","0:2","4:0","0:1","1:2","7:0","3:3","3:1","4:0","5:0","6:1","5:0","2:3","2:0","8:0","9:1","1:0","2:2","1:0","8:0","4:3","2:0","5:0","7:0","3:1","6:0","0:2","1:1","4:0","7:0","3:0","4:1","2:1","3:1","4:0","3:2","1:2","1:2","0:1","0:1","1:1","6:3","1:3","2:3","5:2","3:3","3:1","0:1","2:0","1:2","2:3","0:3","0:2","2:1","0:1","4:1","0:2","1:3","0:2","3:3","2:2","3:1","2:3","1:2","2:0","0:4","1:0"]
let penalties = ["","","4:2","","","","","","","","","","","4:1","","","","","","","","","","0:3","","","","","","","","","","","","","3:4","","","","","3:4","","","","","","","","","","","","","","5:3","3:4","","","","","","","","2:4","","","","","","","","","","1:4","","","","","","","","3:0","","","","","","","","","","","","4:3","","","","","4:3","","","","","","","","","","","","","","3:5","4:3","","","","","","",""]
let currentIndex = -1

// Function to pick a random match and show result
function showRandomResult() {
    currentIndex = Math.randomRange(0, results.length - 1)
    basic.showString(results[currentIndex])
}

// Function to show penalty result
function showPenaltyResult() {
    if (currentIndex >= 0) {
        if (penalties[currentIndex] !== "") {
            basic.showString(penalties[currentIndex])
        } else {
            basic.showString("No penalties")
        }
    }
}

// Display soccer ball at start
basic.showLeds(`
    . # . # .
    # . # . #
    . # # # .
    # . # . #
    . # . # .
`)
basic.pause(1000)
basic.clearScreen()

// Button A: Pick random match and show result
input.onButtonPressed(Button.A, function() {
    showRandomResult()
})

// Button B: Show penalty result if available
input.onButtonPressed(Button.B, function() {
    showPenaltyResult()
})

// Shake: Show random "A" or "H"
input.onGesture(Gesture.Shake, function() {
    if (Math.randomBoolean()) {
        basic.showString("A")
    } else {
        basic.showString("H")
    }
})
3 „Gefällt mir“