Operácie

Datalogger so záznamom: Rozdiel medzi revíziami

Zo stránky SensorWiki

Balogh (diskusia | príspevky)
Bez shrnutí editace
Balogh (diskusia | príspevky)
Bez shrnutí editace
Riadok 18: Riadok 18:
<tabs>
<tabs>
<tab name="Javascript"><source lang="javascript">
<tab name="Javascript"><source lang="javascript">
let logging = false
    datalogger.setColumnTitles("ms","x")
loops.everyInterval(100, function ()
{
  if (logging)
  {
    datalogger.log(
        datalogger.createCV("ms", control.millis()),
        datalogger.createCV("x", input.acceleration(Dimension.X))
        )
  }
})
input.onButtonPressed(Button.A, function () {
    logging = !(logging)
    if (logging) {
        basic.showIcon(IconNames.Yes)
    } else {
        basic.clearScreen()
    }
})
datalogger.onLogFull(function ()
{
    logging = false
    basic.showIcon(IconNames.No)
})
input.onButtonPressed(Button.AB, function () {
    if (input.logoIsPressed()) {
        basic.showIcon(IconNames.Angry)
        datalogger.deleteLog()
        logging = false
        datalogger.setColumnTitles(
        "ms",
        "x"
        )
    }
})
</source></tab>
</source></tab>
<tab name="MS Python"><source lang="python" style="background: LightBlue;">
<tab name="MS Python"><source lang="python" style="background: LightBlue;">
logging = False
datalogger.set_column_titles("ms", "x")
def on_every_interval():
    if logging:
        datalogger.log(datalogger.create_cv("ms", control.millis()),
            datalogger.create_cv("x", input.acceleration(Dimension.X)))
loops.every_interval(100, on_every_interval)
def on_button_pressed_a():
    global logging
    logging = not (logging)
    if logging:
        basic.show_icon(IconNames.YES)
    else:
        basic.clear_screen()
input.on_button_pressed(Button.A, on_button_pressed_a)
def on_log_full():
    global logging
    logging = False
    basic.show_icon(IconNames.NO)
datalogger.on_log_full(on_log_full)
def on_button_pressed_ab():
    global logging
    if input.logo_is_pressed():
        basic.show_icon(IconNames.ANGRY)
        datalogger.delete_log()
        logging = False
        datalogger.set_column_titles("ms", "x")
input.on_button_pressed(Button.AB, on_button_pressed_ab)
</source></tab>
</source></tab>
<tab name="uPython"><source lang="python" style="background: LightBlue;">
<tab name="uPython"><source lang="python" style="background: LightBlue;">

Verzia z 18:28, 18. marec 2024


S novým Extension balíkom, ktorý sa volá príhodne Datalogger, je možné namerané dáta zaznamenávať do flash pamäte mikropočítača, ktorá sa sprístupní po pripojení micro:bitu ako flash disk, na ktorom nájdeme namerané dáta ako .html súbor s ktorým potom vieme ďalej pracovať.

Základné informácie nájdete aj tu:



let logging = false
    datalogger.setColumnTitles("ms","x")



loops.everyInterval(100, function () 
{
  if (logging) 
   {
     datalogger.log(
        datalogger.createCV("ms", control.millis()),
        datalogger.createCV("x", input.acceleration(Dimension.X))
        )
   }
})


input.onButtonPressed(Button.A, function () {
    logging = !(logging)
    if (logging) {
        basic.showIcon(IconNames.Yes)
    } else {
        basic.clearScreen()
    }
})





datalogger.onLogFull(function () 
{
    logging = false
    basic.showIcon(IconNames.No)
})




input.onButtonPressed(Button.AB, function () {
    if (input.logoIsPressed()) {
        basic.showIcon(IconNames.Angry)
        datalogger.deleteLog()
        logging = false
        datalogger.setColumnTitles(
        "ms",
        "x"
        )
    }
})
logging = False
datalogger.set_column_titles("ms", "x")


def on_every_interval():
    if logging:
        datalogger.log(datalogger.create_cv("ms", control.millis()),
            datalogger.create_cv("x", input.acceleration(Dimension.X)))
loops.every_interval(100, on_every_interval)




def on_button_pressed_a():
    global logging
    logging = not (logging)
    if logging:
        basic.show_icon(IconNames.YES)
    else:
        basic.clear_screen()
input.on_button_pressed(Button.A, on_button_pressed_a)




def on_log_full():
    global logging
    logging = False
    basic.show_icon(IconNames.NO)
datalogger.on_log_full(on_log_full)




def on_button_pressed_ab():
    global logging
    if input.logo_is_pressed():
        basic.show_icon(IconNames.ANGRY)
        datalogger.delete_log()
        logging = False
        datalogger.set_column_titles("ms", "x")
input.on_button_pressed(Button.AB, on_button_pressed_ab)


Späť na zoznam príkladov....