Skip to content

Instantly share code, notes, and snippets.

@hasumikin
Last active March 15, 2019 06:28
Show Gist options
  • Save hasumikin/fce20fddaec217382e4fd5b7734836d7 to your computer and use it in GitHub Desktop.
Save hasumikin/fce20fddaec217382e4fd5b7734836d7 to your computer and use it in GitHub Desktop.

clone template

git clone https://github.com/hasumikin/mrubyc-template-esp32.git 03
cd 03

edit source

  • create mrblib/loops/master.rb
  • create mrblib/models/greeter.rb
  • edit main/main.c (you can replace whole of the file with code below)

build, flash and run

make
make flash
make monitor
# mrblib/models/greeter.rb
class Greeter
def greet
puts "Hello World!"
end
end
/* main/main.c */
#include "mrubyc.h"
#include "models/greeter.h"
#include "loops/master.h"
#define MEMORY_SIZE (1024*40)
static uint8_t memory_pool[MEMORY_SIZE];
void app_main(void) {
mrbc_init(memory_pool, MEMORY_SIZE);
mrbc_create_task( greeter, 0 );
mrbc_create_task( master, 0 );
mrbc_run();
}
# mrblib/loops/master.rb
greeter = Greeter.new
while true
greeter.greet
sleep 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment