summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2016-04-30 19:44:03 +0100
committerdakkar <dakkar@thenautilus.net>2016-04-30 19:47:14 +0100
commit7ce33e20a449d7883a6d3404fecbc7633ca9d371 (patch)
treea3ced0bb9f9768c92ffc5c8c5358e5f3e1be9c98
parentnew anime day (diff)
downloadthenautilus-7ce33e20a449d7883a6d3404fecbc7633ca9d371.tar.gz
thenautilus-7ce33e20a449d7883a6d3404fecbc7633ca9d371.tar.bz2
thenautilus-7ce33e20a449d7883a6d3404fecbc7633ca9d371.zip
new keepon-eeg stuff
-rw-r--r--src/HW/mindflex/document.en.rest.txt124
-rw-r--r--src/HW/mindflex/document.it.rest.txt122
2 files changed, 95 insertions, 151 deletions
diff --git a/src/HW/mindflex/document.en.rest.txt b/src/HW/mindflex/document.en.rest.txt
index 472a19a..b79320d 100644
--- a/src/HW/mindflex/document.en.rest.txt
+++ b/src/HW/mindflex/document.en.rest.txt
@@ -7,36 +7,35 @@ Playing with a Mind Flex
- software
Some time ago I bought a `Mind Flex`_, with the idea of interfacing it
-to some motors, and control a thing **with my mind**!.
+to some motors, and control a thing **with my mind**!. As for the
+"thing", I bought a `Keepon`_.
-Of course it sat unused for years.
+Of course they sat unused for years.
Then I got myself a `MicroView`_, because it was pretty.
Of course it, too, sat unused for years.
-Today I finally put the two together.
+I've finally started putting the three together.
.. _`Mind Flex`: http://store.neurosky.com/products/mindflex
-.. _`MicroView`: http://learn.microview.io/Intro/general-overview-of-microview.html
+.. _`Keepon`: http://www.mykeepon.com/
+.. _`MicroView`:
+ http://learn.microview.io/Intro/general-overview-of-microview.html
Software setup
==============
First of all, I had to set up the Arduino IDE + compilers. On a Gentoo
-system it's a bit tricky, but thanks to `a very clear post on the
-Apollo NG site`_ I got it installed::
+system it used to be a bit tricky (although there is `a very clear post on the
+Apollo NG site`_ that helped), but now it's just::
emerge arduino crossdev dev-java/rxtx
- USE="multilib -cxx" crossdev -s1 --without-headers \
- --target avr \
- --gcc 4.5.4 --binutils 2.21.1-r1 --libc 1.7.0
-
- USE="multilib cxx" crossdev -s4 \
- --target avr \
- --gcc 4.5.4 --binutils 2.21.1-r1 --libc 1.7.0
+ USE="multilib cxx" crossdev --target avr
+These additional symlinks are probably still needed, though::
+
ln -nsf /usr/x86_64-pc-linux-gnu/avr/lib/ldscripts \
/usr/avr/lib/ldscripts
@@ -49,7 +48,8 @@ Apollo NG site`_ I got it installed::
ln -nsf avr6/crtm2561.o .
ln -nsf avr6/crtm2560.o .
-.. _`a very clear post on the Apollo NG site`: https://apollo.open-resource.org/mission:log:2015:01:20:gentoo-crossdev-compile-avr-gcc-for-arduino-and-cura
+.. _`a very clear post on the Apollo NG site`:
+ https://apollo.open-resource.org/mission:log:2015:01:20:gentoo-crossdev-compile-avr-gcc-for-arduino-and-cura
Arduino libraries
-----------------
@@ -71,8 +71,14 @@ Note that the MicroView library needs to be in a folder called
``MicroView``, not ``MicroView-Arduino-Library``: the Arduino IDE
really dislikes dashes in library names.
-.. _`read the Neurosky EEG data`: https://github.com/kitschpatrol/Brain
-.. _`control the MicroView hardware`: https://github.com/geekammo/MicroView-Arduino-Library/
+I also copied code from `BeatBots' GitHub repository`_.
+
+.. _`read the Neurosky EEG data`:
+ https://github.com/kitschpatrol/Brain
+.. _`control the MicroView hardware`:
+ https://github.com/geekammo/MicroView-Arduino-Library/
+.. _`BeatBots' GitHub repository`:
+ https://github.com/beatbots/mykeepon
Hardware setup
==============
@@ -85,69 +91,35 @@ separately, the Neurosky board seemed to have serious difficulty
getting a signal, probably because of noise on the power line.
I then connected (currently via a small breadboard) the MicroView to
-the wires: ground to pin 8, power to pin 16, signal to pin 9 (serial
-receive).
+the wires: ground to ground, power to VIN, signal to pin Rx.
.. _`Frontier Nerds`: http://www.frontiernerds.com/brain-hack
+For the Keepon, I connected four wires as explained by BeatBots:
+ground to ground, power to A0 (to read when the Keepon is turned on),
+clock to A5, data to A4.
+
The program
===========
-This is the very simple program I wrote::
-
- #include <MicroView.h>
- #include <Brain.h>
-
- // the MindFlex is connected to the serial input
- Brain brain(Serial);
-
- void setup() {
- // the MindFlex speaks 9600 bps
- Serial.begin(9600);
- // setup the MicroView display
- uView.begin();
- uView.clear(ALL);
- // use the smallest font, 5x7
- uView.setFontType(0);
- }
-
- const int hist_width=3;
- const int hist_pad=1;
-
- void loop() {
- if (brain.update()) { // do we have data to show?
- uView.clear(PAGE);
-
- // print the signal quality, 0=good, 200=no signal
- uView.setCursor(0,0); uView.print(brain.readSignalQuality());
-
- // print the two "high level" signals
- uView.setCursor(0,9); uView.print(brain.readAttention());
- uView.setCursor(18,9); uView.print(brain.readMeditation());
-
- // we then have 8 frequency bands
- const uint32_t* power = brain.readPowerArray();
- // find the maximum value, for scaling
- uint32_t max_value=0;
- for (int x=0;x<8;++x) {
- if (power[x] > max_value) {
- max_value = power[x];
- }
- }
-
- // draw a simple bar chart
- for (int x=0;x<8;++x) {
- int x0 = (hist_width + hist_pad) * x;
- // we have 30 vertical pixels
- int height = power[x] * 30 / max_value;
- for (int o=0;o<hist_width;++o) {
- uView.lineV(x0+o,47-height,height);
- }
- }
-
- // blit the buffer to the display
- uView.display();
- }
- }
-
-And that's it.
+You can `browse the repository for the program`_; I'm using EMACS and the
+`Arduino Makefile`_, instead of the normal IDE, because I like
+command-line interfaces better than point&click, and also because my
+C++ is so rusty that the real-time feedback of Flymake is necessary.
+
+Currently working:
+
+* read from the Neurosky
+* get control of the Keepon every time it's turned on
+* queue commands to the Keepon
+* show all status on the MicroView
+
+Future work:
+
+* read the status of the Keepon (button presses, sensors, maybe ever
+ microphone?)
+* write some more interesting logic to map brain readings to movements
+
+.. _`browse the repository for the program`:
+ https://www.thenautilus.net/cgit/keepon-eeg/tree/
+.. _`Arduino Makefile`: https://github.com/sudar/Arduino-Makefile
diff --git a/src/HW/mindflex/document.it.rest.txt b/src/HW/mindflex/document.it.rest.txt
index abef570..ad73aee 100644
--- a/src/HW/mindflex/document.it.rest.txt
+++ b/src/HW/mindflex/document.it.rest.txt
@@ -7,36 +7,35 @@ Giocherellare con un Mind Flex
- software
Qualche tempo fa comprai un `Mind Flex`_, con l'idea di interfacciarlo
-a qualche motore, e controllare qualcosa **con la mente**!
+a qualche motore, e controllare qualcosa **con la mente**! Il
+"qualcosa" sarebbe stato un `Keepon`_.
-Ovviamente è rimasto su uno scaffale per anni.
+Ovviamente sono rimasti su uno scaffale per anni.
Successivamente mi sono procurato un `MicroView`_, perché è bellino.
Ovviamente, pure quello è rimasto su uno scaffale per anni.
-Oggi ho finalmente messo assieme le due cose.
+Di recente ho finalmente cominciato a mettere assieme le tre cose.
.. _`Mind Flex`: http://store.neurosky.com/products/mindflex
-.. _`MicroView`: http://learn.microview.io/Intro/general-overview-of-microview.html
+.. _`Keepon`: http://www.mykeepon.com/
+.. _`MicroView`:
+ http://learn.microview.io/Intro/general-overview-of-microview.html
Il software
===========
Prima di tutto, ho dovuto mettere su l'IDE Arduino e il
-compilatore. Farlo su una Gentoo è meno ovvio di quanto dovrebbe, ma
-grazie a `un post molto chiaro su sito Apollo NG`_ sono riuscito a
-installare il tutto::
+compilatore. Quando ho cominciato, farlo su una Gentoo era meno ovvio
+di quanto avrebbe dovuto (anche se c'è `un post molto chiaro su sito
+Apollo NG`_ che aiuta molto), ma ora è facile::
emerge arduino crossdev dev-java/rxtx
- USE="multilib -cxx" crossdev -s1 --without-headers \
- --target avr \
- --gcc 4.5.4 --binutils 2.21.1-r1 --libc 1.7.0
+ USE="multilib cxx" crossdev --target avr
- USE="multilib cxx" crossdev -s4 \
- --target avr \
- --gcc 4.5.4 --binutils 2.21.1-r1 --libc 1.7.0
+Questi symlink sono probabilmente ancora necessari::
ln -nsf /usr/x86_64-pc-linux-gnu/avr/lib/ldscripts \
/usr/avr/lib/ldscripts
@@ -72,8 +71,14 @@ Notare che la libreria del MicroView deve stare in una cartella
chiamata ``MicroView``, e non ``MicroView-Arduino-Library``: l'IDE
Arduino ha delle restrizioni sui nomi delle librerie.
-.. _`leggere i dati del EEG Neurosky`: https://github.com/kitschpatrol/Brain
-.. _`controllare l'hardware del Microview`: https://github.com/geekammo/MicroView-Arduino-Library/
+Ho copiato un po' di codice dal `repository Github di BeatBots`_.
+
+.. _`leggere i dati del EEG Neurosky`:
+ https://github.com/kitschpatrol/Brain
+.. _`controllare l'hardware del Microview`:
+ https://github.com/geekammo/MicroView-Arduino-Library/
+.. _`repository Github di BeatBots`:
+ https://github.com/beatbots/mykeepon
L'hardware
==========
@@ -87,70 +92,37 @@ prendere il segnale, probabilmente a causa del rumore sulla linea di
alimentazione.
Ho poi connesso (tramite una piccola breadboard, per il momento) il
-MicroView ai fili: massa al piedino 8, alimentazione al piedino 16,
-segnale al piedino 9 (ingresso seriale).
+MicroView ai fili: massa a massa, alimentazione a VIN, segnale al
+piedino di ingresso seriale.
.. _`Frontier Nerds`: http://www.frontiernerds.com/brain-hack
+Per il Keepon, ho connesso i quattro fili come spiega BeatBots: massa
+a massa, alimentazione a A0 (così possiamo notare quando il Keepon
+viene accesso), clock a A5, dati a A4.
+
Il programma
============
-Questo è il programmino, molto semplice, che ho scritto::
-
- #include <MicroView.h>
- #include <Brain.h>
-
- // il MindFlex è connesso alla seriale
- Brain brain(Serial);
-
- void setup() {
- // il MindFlex parla a 9600 bps
- Serial.begin(9600);
- // prepara il display del MicroView
- uView.begin();
- uView.clear(ALL);
- // usa il font più piccolo, 5x7
- uView.setFontType(0);
- }
-
- const int hist_width=3;
- const int hist_pad=1;
-
- void loop() {
- if (brain.update()) { // abbiamo dati da mostrare?
- uView.clear(PAGE);
-
- // mostra la qualità del segnale, 0=buono, 200=nessun segnale
- uView.setCursor(0,0); uView.print(brain.readSignalQuality());
-
- // mostra i due segnali di "alto livello"
- uView.setCursor(0,9); uView.print(brain.readAttention());
- uView.setCursor(18,9); uView.print(brain.readMeditation());
-
- // ci sono poi 8 bande di frequenza
- const uint32_t* power = brain.readPowerArray();
- // trova il massimo, per scalarle
- uint32_t max_value=0;
- for (int x=0;x<8;++x) {
- if (power[x] > max_value) {
- max_value = power[x];
- }
- }
-
- // disegna un semplice istogramma
- for (int x=0;x<8;++x) {
- int x0 = (hist_width + hist_pad) * x;
- // abbiamo 30 pixel in verticale
- int height = power[x] * 30 / max_value;
- for (int o=0;o<hist_width;++o) {
- uView.lineV(x0+o,47-height,height);
- }
- }
-
- // copia il buffer sul display
- uView.display();
- }
- }
-
-E questo è tutto.
+Potete `guardare il repository con il programma`_; uso EMACS e
+l'`Arduino Makefile`_, invece della IDE, perché preferisco la riga di
+comando, e anche perché il mio C++ è talmente arrugginito che senza
+l'aiuto di Flymake non scriverei nulla di buono.
+
+Cose che funzionano:
+
+* leggere dati dal Neurosky
+* ottenere il controllo del Keepon ogni volta che viene acceso
+* accodare comandi per il Keepon
+* mostrare lo stato completo sul MicroView
+
+In futuro:
+
+* leggere lo stato del Keepon (pulsanti, sensori, magari anche il
+ microfono?)
+* scrivere un po' di logica non banale per mappare le letture del
+ Neurosky ai movimenti del Keepon
+.. _`guardare il repository con il programma`:
+ https://www.thenautilus.net/cgit/keepon-eeg/tree/
+.. _`Arduino Makefile`: https://github.com/sudar/Arduino-Makefile