mirror of
https://forge.apps.education.fr/blender-edutech/blender-edutech-tutoriels.git
synced 2024-01-27 09:42:33 +01:00
Tutoriel 6 : déplacement manuel
This commit is contained in:
parent
e825067dc6
commit
e00e7c037b
Binary file not shown.
@ -1,6 +1,7 @@
|
|||||||
|
#include "Servo.h"
|
||||||
#include "Wire.h"
|
#include "Wire.h"
|
||||||
#include "Grove_LED_Matrix_Driver_HT16K33.h"
|
|
||||||
#include "MPU6050.h"
|
#include "MPU6050.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* 6-labyrinthe-arduino.ino
|
* 6-labyrinthe-arduino.ino
|
||||||
@ -10,11 +11,43 @@
|
|||||||
* @authors: Philippe Roy <philippe.roy@ac-grenoble.fr>
|
* @authors: Philippe Roy <philippe.roy@ac-grenoble.fr>
|
||||||
* @copyright: Copyright (C) 2023 Philippe Roy
|
* @copyright: Copyright (C) 2023 Philippe Roy
|
||||||
* @license: GNU GPL
|
* @license: GNU GPL
|
||||||
*
|
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* IMU - I2C
|
* Précautions :
|
||||||
|
* - Régler l'alimentation à 6V DC - 3 A maxi
|
||||||
|
* - Brochage pupitre : joystick -> A0, bouton -> D2, voyant -> D3
|
||||||
|
* - Brochage capteur : IMU en I2C
|
||||||
|
* - Brochage actionneurs : axes (x,y) -> D5/D6 (x,y)
|
||||||
|
* - Mettre les servomoteurs à 45° soit 1000 µs
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* Servomoteurs
|
||||||
|
* Alimentation par servoteur : 6V DC à 1.5 A
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
Servo servo_x; // Servomoteur axe x
|
||||||
|
Servo servo_y; // Servomoteur axe y
|
||||||
|
const int servo_x_pin = 5; // Servomoteur axe x sur broche D5
|
||||||
|
const int servo_y_pin = 6; // Servomoteur axe y sur broche D6
|
||||||
|
int angle_x_ms; // Angle en µs : 500 -> 0° ; 1500->90° et 2500-> 180°
|
||||||
|
int angle_y_ms; // Angle en µs : 500 -> 0° ; 1500->90° et 2500-> 180°
|
||||||
|
const float servo_pas_maxi = 20; // Pas angulaire (µs) maxi (pas de calcul en int)
|
||||||
|
const int servo_pas_auto = 5; // Pas angulaire (µs) pour le mode auto-horizontalité
|
||||||
|
int servo_pas = 0; // Pas angulaire (µs) du mouvement en cours (pas propotionel au joystick)
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* Pupitre : joystick + 1 bouton + 1 voyant
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
const int bt_pin = 2; // Bouton du mode d'auto-horizontalité sur la broche D2
|
||||||
|
const int led_pin = 3; // Led du mode d'auto-horizontalité sur la broche D3
|
||||||
|
const int jstk_x_pin = A1; // Joystick axe x sur la broche A1
|
||||||
|
const int jstk_y_pin = A0; // Joystick axe y sur la broche A0
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* Capteur IMU - I2C
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
MPU6050 accelgyro;
|
MPU6050 accelgyro;
|
||||||
@ -31,18 +64,9 @@ String roll_txt;
|
|||||||
String pitch_txt;
|
String pitch_txt;
|
||||||
String serial_msg_int_txt;
|
String serial_msg_int_txt;
|
||||||
|
|
||||||
/******************************************************************************
|
bool auto_horizontal = false; // Flag du mode de la mise à l'auto-horizontalité
|
||||||
* Led Matrix - I2C
|
bool auto_horizontal_mvt = false; // Flag du mouvement de l'auto-horizontalité
|
||||||
******************************************************************************/
|
const int auto_horizontal_sensibilite = 1; // Angle maxi pour l'auto-horizontalité
|
||||||
|
|
||||||
Matrix_8x8 matrix;
|
|
||||||
|
|
||||||
/******************************************************************************
|
|
||||||
* Communication serie
|
|
||||||
******************************************************************************/
|
|
||||||
|
|
||||||
String serial_msg = ""; // Message
|
|
||||||
bool serial_msg_complet = false; // Flag de message complet
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Initialisation
|
* Initialisation
|
||||||
@ -50,20 +74,28 @@ bool serial_msg_complet = false; // Flag de message complet
|
|||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
|
||||||
// Liaison série
|
// Liaison série
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
|
||||||
// IMU
|
// Servomoteurs
|
||||||
Wire.begin();
|
servo_x.attach(servo_x_pin); // Brochage
|
||||||
accelgyro.initialize();
|
servo_y.attach(servo_y_pin); // Brochage
|
||||||
|
angle_x_ms = 1000; // 500 -> 0°, 1500 -> 90° et 2500-> 180°
|
||||||
|
angle_y_ms = 1000; // 500 -> 0°, 1500 -> 90° et 2500-> 180°
|
||||||
|
servo_x.writeMicroseconds(angle_x_ms); // 1000 -> 45° */
|
||||||
|
servo_y.writeMicroseconds(angle_y_ms); // 1000 -> 45° */
|
||||||
|
|
||||||
// Led Matrix
|
// Pupitre
|
||||||
matrix.init();
|
pinMode(bt_pin, INPUT);
|
||||||
matrix.setBrightness(0);
|
pinMode(jstk_x_pin, INPUT);
|
||||||
matrix.setBlinkRate(BLINK_OFF);
|
pinMode(jstk_y_pin, INPUT);
|
||||||
matrix.clear();
|
pinMode(led_pin, OUTPUT);
|
||||||
matrix.display();
|
|
||||||
}
|
// IMU
|
||||||
|
Wire.begin();
|
||||||
|
accelgyro.initialize();
|
||||||
|
Serial.println();
|
||||||
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Boucle principale
|
* Boucle principale
|
||||||
@ -94,52 +126,127 @@ void loop() {
|
|||||||
Serial.print(",");
|
Serial.print(",");
|
||||||
Serial.print(pitch_txt);
|
Serial.print(pitch_txt);
|
||||||
Serial.println();
|
Serial.println();
|
||||||
|
|
||||||
/*****
|
/*****
|
||||||
* Led Matrix : UPBGE -> Arduino
|
* Mouvement manuel : Axe x
|
||||||
*****/
|
*****/
|
||||||
|
|
||||||
if (serial_msg_complet) {
|
|
||||||
matrix.clear();
|
|
||||||
int xy= serial_msg.toInt(); // Message par chiffre : XY
|
|
||||||
|
|
||||||
// Position de la bille en x et y
|
// en C : sur x de 237 à 784 (centre à 510) et sur y de 249 à 773 (centre à 511)
|
||||||
if (xy<90) {
|
// en Python de 0,25 à 0,75 avec une zone morte entre 0,48 et 0,52 (soit 491 et 532 pour une base sur 1024)
|
||||||
int x= xy/10;
|
|
||||||
int y= xy-(x*10);
|
if ((analogRead(jstk_x_pin) <491) or (analogRead(jstk_x_pin) >532))
|
||||||
matrix.writePixel(x, y, true);
|
{
|
||||||
|
|
||||||
|
// Désactivation de l'horizontalité automatique
|
||||||
|
if (auto_horizontal)
|
||||||
|
{
|
||||||
|
auto_horizontal = false;
|
||||||
|
digitalWrite(led_pin, LOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mouvement x -
|
||||||
|
if (analogRead(jstk_x_pin) <491)
|
||||||
|
{
|
||||||
|
servo_pas = (servo_pas_maxi/(511-249))*(511-analogRead(jstk_x_pin));
|
||||||
|
angle_x_ms=angle_x_ms-servo_pas;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mouvement x +
|
||||||
|
if (analogRead(jstk_x_pin) >532)
|
||||||
|
{
|
||||||
|
servo_pas = (servo_pas_maxi/(773-511))*(analogRead(jstk_x_pin)-511);
|
||||||
|
angle_x_ms=angle_x_ms+servo_pas;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fin de course logiciel
|
||||||
|
if (angle_x_ms<600)
|
||||||
|
angle_x_ms=600;
|
||||||
|
if (angle_x_ms>1600)
|
||||||
|
angle_x_ms=1600;
|
||||||
|
|
||||||
|
// Moteur x
|
||||||
|
servo_x.writeMicroseconds(angle_x_ms);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****
|
||||||
|
* Mouvement manuel : Axe y
|
||||||
|
*****/
|
||||||
|
|
||||||
|
// en C : sur x de 249 à 773 (centre à 511) et sur y de 237 à 784 (centre à 510)
|
||||||
|
// en Python de 0,25 à 0,75 avec une zone morte entre 0,48 et 0,52 (soit 491 et 532 pour une base sur 1024)
|
||||||
|
|
||||||
|
if ((analogRead(jstk_y_pin) <491) or (analogRead(jstk_y_pin) >532))
|
||||||
|
{
|
||||||
|
// Désactivation de l'horizontalité automatique
|
||||||
|
if (auto_horizontal)
|
||||||
|
{
|
||||||
|
auto_horizontal = false;
|
||||||
|
digitalWrite(led_pin, LOW);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mouvement y -
|
||||||
|
if (analogRead(jstk_y_pin) <491)
|
||||||
|
{
|
||||||
|
servo_pas = (servo_pas_maxi/(511-237))*(511-analogRead(jstk_y_pin));
|
||||||
|
angle_y_ms=angle_y_ms-servo_pas;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mouvement y +
|
||||||
|
if (analogRead(jstk_y_pin) >532)
|
||||||
|
{
|
||||||
|
servo_pas = (servo_pas_maxi/(784-511))*(analogRead(jstk_y_pin)-511);
|
||||||
|
angle_y_ms=angle_y_ms+servo_pas;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fin de course logiciel
|
||||||
|
if (angle_y_ms<600)
|
||||||
|
angle_y_ms=600;
|
||||||
|
if (angle_y_ms>1600)
|
||||||
|
angle_y_ms=1600;
|
||||||
|
|
||||||
|
// Moteur y
|
||||||
|
servo_y.writeMicroseconds(angle_y_ms);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****
|
||||||
|
* Mise à l'horizontale automatique
|
||||||
|
*****/
|
||||||
|
|
||||||
|
if (digitalRead(bt_pin) == HIGH)
|
||||||
|
auto_horizontal = true;
|
||||||
|
|
||||||
|
if (auto_horizontal)
|
||||||
|
{
|
||||||
|
digitalWrite(led_pin, HIGH); // Led
|
||||||
|
auto_horizontal_mvt = false;
|
||||||
|
|
||||||
// Chute
|
// Mouvement
|
||||||
if (xy==91) {
|
if ((roll_deg < -1) or (roll_deg > 1) or (pitch_deg < -1) or (pitch_deg > 1))
|
||||||
matrix.writeOnePicture(0x81423c0000666600);
|
auto_horizontal_mvt = true;
|
||||||
matrix.display();
|
if (roll_deg < -1)
|
||||||
delay(1000);
|
angle_y_ms=angle_y_ms-servo_pas_auto;
|
||||||
Serial.println("start"); // Relance le jeu
|
if (roll_deg > 1)
|
||||||
}
|
angle_y_ms=angle_y_ms+servo_pas_auto;
|
||||||
|
if (pitch_deg < -1)
|
||||||
|
angle_x_ms=angle_x_ms+servo_pas_auto;
|
||||||
|
if (pitch_deg > 1)
|
||||||
|
angle_x_ms=angle_x_ms-servo_pas_auto;
|
||||||
|
|
||||||
// Victoire
|
// Fin de course logiciel
|
||||||
if (xy==92) matrix.writeOnePicture(0x003c428100666600);
|
if (angle_x_ms<600)
|
||||||
|
angle_x_ms=600;
|
||||||
|
if (angle_x_ms>1600)
|
||||||
|
angle_x_ms=1600;
|
||||||
|
if (angle_y_ms<600)
|
||||||
|
angle_y_ms=600;
|
||||||
|
if (angle_y_ms>1600)
|
||||||
|
angle_y_ms=1600;
|
||||||
|
|
||||||
// Affichage
|
// Moteurs x et y
|
||||||
matrix.display();
|
if (auto_horizontal_mvt)
|
||||||
serial_msg = "";
|
{
|
||||||
serial_msg_complet = false;
|
servo_x.writeMicroseconds(angle_x_ms);
|
||||||
}
|
servo_y.writeMicroseconds(angle_y_ms);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************
|
|
||||||
* Évènement provoqué par UPBGE (via la liaison série)
|
|
||||||
******************************************************************************/
|
|
||||||
|
|
||||||
void serialEvent() {
|
|
||||||
while (Serial.available()) {
|
|
||||||
char inChar = (char)Serial.read();
|
|
||||||
serial_msg += inChar;
|
|
||||||
if (inChar == '\n') {
|
|
||||||
serial_msg_complet = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,336 +0,0 @@
|
|||||||
/*
|
|
||||||
Grove_LED_Matrix_Driver_HT16K33.cpp
|
|
||||||
A library for Grove - Grove - LED Matrix Driver(HT16K33 with 8x8 LED Matrix)
|
|
||||||
|
|
||||||
Copyright (c) 2018 seeed technology inc.
|
|
||||||
Website : www.seeed.cc
|
|
||||||
Author : Jerry Yip
|
|
||||||
Create Time: 2018-06
|
|
||||||
Version : 0.1
|
|
||||||
Change Log :
|
|
||||||
|
|
||||||
The MIT License (MIT)
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "Grove_LED_Matrix_Driver_HT16K33.h"
|
|
||||||
#include "Seeed_Font.h"
|
|
||||||
|
|
||||||
|
|
||||||
HT16K33::HT16K33() {
|
|
||||||
}
|
|
||||||
|
|
||||||
void HT16K33::init(uint8_t addr) {
|
|
||||||
_addr = addr;
|
|
||||||
// turn on oscillator
|
|
||||||
I2Cdev::writeBytes(_addr, 0x21, 0, (uint8_t*)NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void HT16K33::setBrightness(uint8_t brightness) {
|
|
||||||
I2Cdev::writeBytes(_addr, (0xE0 | brightness), 0, (uint8_t*)NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void HT16K33::setBlinkRate(blink_type_t blink_type) {
|
|
||||||
I2Cdev::writeBytes(_addr, (0x80 | 0x01 | (blink_type << 1)), 0, (uint8_t*)NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
Matrix_8x8::Matrix_8x8() {
|
|
||||||
_orientation = DISPLAY_ROTATE_0;
|
|
||||||
_offset_x = 0;
|
|
||||||
_offset_y = 0;
|
|
||||||
_cursor_start = 0;
|
|
||||||
_cursor_end = 0;
|
|
||||||
_cursor_steps = 1;
|
|
||||||
_ms = 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Matrix_8x8::setDisplayOffset(int8_t x, int8_t y) {
|
|
||||||
if ((x < -8) || (x > 8)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ((y < -8) || (y > 8)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_offset_x = x;
|
|
||||||
_offset_y = y;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Matrix_8x8::setDisplayOrientation(uint8_t orientation) {
|
|
||||||
_orientation = (orientation_type_t)orientation;
|
|
||||||
}
|
|
||||||
|
|
||||||
// _cursor_end - _cursor_start >= 1
|
|
||||||
void Matrix_8x8::display() {
|
|
||||||
// get data from _big_buffer[] and write to HT16K33
|
|
||||||
uint8_t line;
|
|
||||||
|
|
||||||
if (_cursor_start > _cursor_end) {
|
|
||||||
uint16_t t;
|
|
||||||
t = _cursor_start;
|
|
||||||
_cursor_start = _cursor_end;
|
|
||||||
_cursor_end = t;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int32_t i = _cursor_start; i <= _cursor_end; i = i + _cursor_steps) {
|
|
||||||
for (uint8_t j = 0; j < 8; j++) {
|
|
||||||
// test
|
|
||||||
line = _big_buffer[(MAX_BIG_BUFFER_SIZE - 8 - i) + j];
|
|
||||||
for (uint8_t k = 0; k < 8; k++) {
|
|
||||||
if (line & 0x01) {
|
|
||||||
// set 1
|
|
||||||
_buffer[2 * j] |= (1 << k);
|
|
||||||
} else {
|
|
||||||
// set 0
|
|
||||||
_buffer[2 * j] &= ~(1 << k);
|
|
||||||
}
|
|
||||||
line = line >> 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// offset
|
|
||||||
if (_offset_y > 0) {
|
|
||||||
for (uint8_t i = 0; i < 8; i++) {
|
|
||||||
_buffer[2 * i] = (_buffer[2 * i] >> _offset_y);
|
|
||||||
}
|
|
||||||
} else if (_offset_y < 0) {
|
|
||||||
for (uint8_t i = 0; i < 8; i++) {
|
|
||||||
_buffer[2 * i] = (_buffer[2 * i] << (-_offset_y));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (_offset_x > 0) {
|
|
||||||
for (int8_t i = (7 - _offset_x); i >= 0; i--) {
|
|
||||||
_buffer[2 * (i + _offset_x)] = _buffer[2 * i];
|
|
||||||
}
|
|
||||||
for (uint8_t i = 0; i < _offset_x; i++) {
|
|
||||||
_buffer[2 * i] = 0;
|
|
||||||
}
|
|
||||||
} else if (_offset_x < 0) {
|
|
||||||
for (uint8_t i = (-_offset_x); i < 8; i++) {
|
|
||||||
_buffer[2 * (i + _offset_x)] = _buffer[2 * i];
|
|
||||||
}
|
|
||||||
|
|
||||||
for (uint8_t i = (8 + _offset_x); i < 8; i++) {
|
|
||||||
_buffer[2 * i] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
I2Cdev::writeBytes(_addr, 0x00, 16, _buffer);
|
|
||||||
delay(_ms);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Matrix_8x8::clear() {
|
|
||||||
memset(_big_buffer, 0, MAX_BIG_BUFFER_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Matrix_8x8::writePixel(uint8_t x, uint16_t y, bool set_on) {
|
|
||||||
if (x > 7) {
|
|
||||||
x = 7;
|
|
||||||
}
|
|
||||||
if (y > (MAX_BIG_BUFFER_SIZE - 1)) {
|
|
||||||
y = MAX_BIG_BUFFER_SIZE - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t y_mod8 = y % 8;
|
|
||||||
// first do spin
|
|
||||||
switch (_orientation) {
|
|
||||||
case DISPLAY_ROTATE_0: {
|
|
||||||
uint8_t t;
|
|
||||||
t = x;
|
|
||||||
x = y_mod8;
|
|
||||||
y_mod8 = t;
|
|
||||||
x = 7 - x;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
// case DISPLAY_ROTATE_90:
|
|
||||||
// break;
|
|
||||||
|
|
||||||
case DISPLAY_ROTATE_180: {
|
|
||||||
uint8_t t;
|
|
||||||
t = x;
|
|
||||||
x = y_mod8;
|
|
||||||
y_mod8 = t;
|
|
||||||
y_mod8 = 7 - y_mod8;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case DISPLAY_ROTATE_270:
|
|
||||||
y_mod8 = 7 - y_mod8;
|
|
||||||
x = 7 - x;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (set_on) {
|
|
||||||
_big_buffer[((MAX_BIG_BUFFER_SIZE / 8 - 1) - (y / 8)) * 8 + y_mod8] |= (1 << x);
|
|
||||||
} else {
|
|
||||||
_big_buffer[((MAX_BIG_BUFFER_SIZE / 8 - 1) - (y / 8)) * 8 + y_mod8] &= ~(1 << x);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Matrix_8x8::writeBar(uint8_t bar) {
|
|
||||||
if (bar > 32) {
|
|
||||||
bar = 32;
|
|
||||||
}
|
|
||||||
Matrix_8x8::writeOnePicture(BARS[bar]);
|
|
||||||
}
|
|
||||||
void Matrix_8x8::writeIcon(uint8_t num) {
|
|
||||||
if (num > 28) {
|
|
||||||
num = 28;
|
|
||||||
}
|
|
||||||
Matrix_8x8::writeOnePicture(ICONS[num]);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Matrix_8x8::writeNumber(int32_t number, uint16_t ms_per_digit) {
|
|
||||||
Matrix_8x8::writeString(String(number), ms_per_digit, ACTION_SCROLLING);
|
|
||||||
}
|
|
||||||
void Matrix_8x8::writeString(String s, uint16_t ms_per_letter, action_type_t mode) {
|
|
||||||
uint8_t pic_number = s.length();
|
|
||||||
if (pic_number > (MAX_BIG_BUFFER_SIZE / 8)) {
|
|
||||||
pic_number = MAX_BIG_BUFFER_SIZE / 8;
|
|
||||||
}
|
|
||||||
if (pic_number == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const char* p_string = s.c_str();
|
|
||||||
_cursor_start = 0;
|
|
||||||
if (mode == ACTION_SCROLLING) {
|
|
||||||
_cursor_steps = 1;
|
|
||||||
|
|
||||||
if (pic_number == 1) {
|
|
||||||
_cursor_end = 0;
|
|
||||||
_ms = ms_per_letter;
|
|
||||||
} else {
|
|
||||||
_cursor_end = pic_number * 8;
|
|
||||||
_ms = ms_per_letter / 8;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (pic_number == 1) {
|
|
||||||
_cursor_end = 0;
|
|
||||||
} else {
|
|
||||||
_cursor_end = pic_number * 8 - 1;
|
|
||||||
}
|
|
||||||
_cursor_steps = 8;
|
|
||||||
_ms = ms_per_letter;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t frame;
|
|
||||||
uint8_t line;
|
|
||||||
|
|
||||||
memset(_big_buffer, 0, MAX_BIG_BUFFER_SIZE);
|
|
||||||
|
|
||||||
for (uint8_t m = 0; m < pic_number; m++) {
|
|
||||||
frame = ASCII[p_string[m] - 32];
|
|
||||||
for (uint8_t i = 0; i < 8; i++) {
|
|
||||||
line = (uint8_t)(frame & 0xff);
|
|
||||||
for (uint8_t j = 7; j != 255; j--) {
|
|
||||||
if (line & 0x01) {
|
|
||||||
Matrix_8x8::writePixel(j, i + m * 8);
|
|
||||||
}
|
|
||||||
line = line >> 1;
|
|
||||||
}
|
|
||||||
frame = frame >> 8;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Matrix_8x8::writeOnePicture(const uint8_t *pic) {
|
|
||||||
Matrix_8x8::writePictures(pic, 1, 0, ACTION_SHIFT);
|
|
||||||
}
|
|
||||||
|
|
||||||
// uint64_t pic
|
|
||||||
void Matrix_8x8::writeOnePicture(uint64_t pic) {
|
|
||||||
Matrix_8x8::writePictures((uint64_t*)&pic, 1, 0, ACTION_SHIFT);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Matrix_8x8::writePictures(const uint8_t *pic, uint8_t pic_number, uint16_t ms_per_pic, action_type_t mode) {
|
|
||||||
if (pic_number > (MAX_BIG_BUFFER_SIZE / 8)) {
|
|
||||||
pic_number = MAX_BIG_BUFFER_SIZE / 8;
|
|
||||||
}
|
|
||||||
if (pic_number == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_cursor_start = 0;
|
|
||||||
if (mode == ACTION_SCROLLING) {
|
|
||||||
_cursor_steps = 1;
|
|
||||||
_ms = ms_per_pic / 8;
|
|
||||||
_cursor_end = pic_number * 8;
|
|
||||||
} else {
|
|
||||||
_cursor_end = pic_number * 8 - 1;
|
|
||||||
_cursor_steps = 8;
|
|
||||||
_ms = ms_per_pic;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t line;
|
|
||||||
|
|
||||||
memset(_big_buffer, 0, MAX_BIG_BUFFER_SIZE);
|
|
||||||
|
|
||||||
for (uint8_t i = 0; i < (8 * pic_number); i++) {
|
|
||||||
line = pic[i];
|
|
||||||
for (uint8_t j = 0; j < 8; j++) {
|
|
||||||
if (line & 0x01) {
|
|
||||||
Matrix_8x8::writePixel(j, i);
|
|
||||||
}
|
|
||||||
line = line >> 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Matrix_8x8::writePictures(const uint64_t *pic, uint8_t pic_number, uint16_t ms_per_pic, action_type_t mode) {
|
|
||||||
if (pic_number > (MAX_BIG_BUFFER_SIZE / 8)) {
|
|
||||||
pic_number = MAX_BIG_BUFFER_SIZE / 8;
|
|
||||||
}
|
|
||||||
if (pic_number == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_cursor_start = 0;
|
|
||||||
if (mode == ACTION_SCROLLING) {
|
|
||||||
_cursor_steps = 1;
|
|
||||||
_ms = ms_per_pic / 8;
|
|
||||||
_cursor_end = pic_number * 8;
|
|
||||||
} else {
|
|
||||||
_cursor_end = pic_number * 8 - 1;
|
|
||||||
_cursor_steps = 8;
|
|
||||||
_ms = ms_per_pic;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t frame;
|
|
||||||
uint8_t line;
|
|
||||||
|
|
||||||
memset(_big_buffer, 0, MAX_BIG_BUFFER_SIZE);
|
|
||||||
|
|
||||||
for (uint8_t m = 0; m < pic_number; m++) {
|
|
||||||
frame = pic[m];
|
|
||||||
for (uint8_t i = 0; i < 8; i++) {
|
|
||||||
line = (uint8_t)(frame & 0xff);
|
|
||||||
for (uint8_t j = 7; j != 255; j--) {
|
|
||||||
if (line & 0x01) {
|
|
||||||
Matrix_8x8::writePixel(j, i + m * 8);
|
|
||||||
}
|
|
||||||
line = line >> 1;
|
|
||||||
}
|
|
||||||
frame = frame >> 8;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,278 +0,0 @@
|
|||||||
/*
|
|
||||||
Grove_LED_Matrix_Driver_HT16K33.h
|
|
||||||
A library for Grove - LED Matrix Driver(HT16K33 with 8x8 LED Matrix)
|
|
||||||
|
|
||||||
Copyright (c) 2018 seeed technology inc.
|
|
||||||
Website : www.seeed.cc
|
|
||||||
Author : Jerry Yip
|
|
||||||
Create Time: 2018-06
|
|
||||||
Version : 0.1
|
|
||||||
Change Log :
|
|
||||||
|
|
||||||
The MIT License (MIT)
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __GROVE_LED_MATRIX_DRIVER_HT16K33__
|
|
||||||
#define __GROVE_LED_MATRIX_DRIVER_HT16K33__
|
|
||||||
|
|
||||||
#include "I2Cdev.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define HT16K33_DEFAULT_I2C_ADDR 0x70
|
|
||||||
// 8*48 means this buffer can store 48 pictures, if you
|
|
||||||
// need more space, please make sure MAX_BIG_BUFFER_SIZE
|
|
||||||
// is a multiple of 8.
|
|
||||||
#define MAX_BIG_BUFFER_SIZE (8*20)
|
|
||||||
|
|
||||||
|
|
||||||
enum orientation_type_t {
|
|
||||||
DISPLAY_ROTATE_0 = 0,
|
|
||||||
DISPLAY_ROTATE_90,
|
|
||||||
DISPLAY_ROTATE_180,
|
|
||||||
DISPLAY_ROTATE_270,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum action_type_t {
|
|
||||||
ACTION_SCROLLING = 0,
|
|
||||||
ACTION_SHIFT,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum blink_type_t {
|
|
||||||
BLINK_OFF = 0,
|
|
||||||
BLINK_2HZ,
|
|
||||||
BLINK_1HZ,
|
|
||||||
};
|
|
||||||
|
|
||||||
class HT16K33 {
|
|
||||||
public:
|
|
||||||
HT16K33();
|
|
||||||
void init(uint8_t addr = HT16K33_DEFAULT_I2C_ADDR);
|
|
||||||
|
|
||||||
/*************************************************************
|
|
||||||
Description
|
|
||||||
Setting the blink rate of matrix
|
|
||||||
Parameter
|
|
||||||
blink_type: BLINK_OFF, BLINK_2HZ, BLINK_1HZ
|
|
||||||
Return
|
|
||||||
Null.
|
|
||||||
*************************************************************/
|
|
||||||
void setBlinkRate(blink_type_t blink_type);
|
|
||||||
|
|
||||||
/*************************************************************
|
|
||||||
Description
|
|
||||||
Setting the brightness of matrix
|
|
||||||
Parameter
|
|
||||||
brightness: 0-15
|
|
||||||
Return
|
|
||||||
Null.
|
|
||||||
*************************************************************/
|
|
||||||
void setBrightness(uint8_t brightness);
|
|
||||||
|
|
||||||
virtual void display();
|
|
||||||
virtual void clear();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
uint8_t _addr;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class Matrix_8x8 : public HT16K33 {
|
|
||||||
|
|
||||||
public:
|
|
||||||
Matrix_8x8();
|
|
||||||
|
|
||||||
/*************************************************************
|
|
||||||
Description
|
|
||||||
Setting the display offset of x-axis and y-axis.
|
|
||||||
This function will activate after call display().
|
|
||||||
Parameter
|
|
||||||
x: The display offset value of horizontal x-axis, range from -8 to 8.
|
|
||||||
y: The display offset value of horizontal y-axis, range from -8 to 8.
|
|
||||||
Return
|
|
||||||
Null.
|
|
||||||
*************************************************************/
|
|
||||||
void setDisplayOffset(int8_t x, int8_t y);
|
|
||||||
|
|
||||||
/*************************************************************
|
|
||||||
Description
|
|
||||||
Setting the display orientation.
|
|
||||||
This function will activate after call writeXXX().
|
|
||||||
Parameter
|
|
||||||
orientation: DISPLAY_ROTATE_0, DISPLAY_ROTATE_90, DISPLAY_ROTATE_180,
|
|
||||||
DISPLAY_ROTATE_270, which means the display will rotate 0°, 90°,180° or 270°.
|
|
||||||
Return
|
|
||||||
Null.
|
|
||||||
*************************************************************/
|
|
||||||
void setDisplayOrientation(uint8_t orientation);
|
|
||||||
|
|
||||||
/*************************************************************
|
|
||||||
Description
|
|
||||||
Display the pixels stored in display buffer on 8x8 matrix.
|
|
||||||
This function should be called after writeXXX(). And this
|
|
||||||
function will block until all the data is shown. For example,
|
|
||||||
if I call writeString("hello", 1000, ACTION_SCROLLING) and
|
|
||||||
display(), then the program will block for 5 seconds(5*1000ms)
|
|
||||||
before it goes to the next sentense.
|
|
||||||
Parameter
|
|
||||||
Null.
|
|
||||||
Return
|
|
||||||
Null.
|
|
||||||
*************************************************************/
|
|
||||||
void display();
|
|
||||||
|
|
||||||
/*************************************************************
|
|
||||||
Description
|
|
||||||
Clear the display buffer.
|
|
||||||
This function will display nothing on 8x8 Matrix after call display().
|
|
||||||
Parameter
|
|
||||||
Null.
|
|
||||||
Return
|
|
||||||
Null.
|
|
||||||
*************************************************************/
|
|
||||||
void clear();
|
|
||||||
|
|
||||||
/*************************************************************
|
|
||||||
Description
|
|
||||||
Set a pixel ON(default) or OFF in display buffer.
|
|
||||||
Call display() to show display buffer.
|
|
||||||
Parameter
|
|
||||||
x: the x-axis position of the pixel
|
|
||||||
y: the y-axis position of the pixel
|
|
||||||
set_on: Set the pixel ON(default) or OFF.
|
|
||||||
Return
|
|
||||||
Null.
|
|
||||||
*************************************************************/
|
|
||||||
void writePixel(uint8_t x, uint16_t y, bool set_on = true);
|
|
||||||
|
|
||||||
/*************************************************************
|
|
||||||
Description
|
|
||||||
Write a bar in display buffer.
|
|
||||||
Call display() to show display buffer.
|
|
||||||
Parameter
|
|
||||||
bar: 0 - 32. 0 is blank and 32 is full.
|
|
||||||
Return
|
|
||||||
Null.
|
|
||||||
*************************************************************/
|
|
||||||
void writeBar(uint8_t bar);
|
|
||||||
|
|
||||||
/*************************************************************
|
|
||||||
Description
|
|
||||||
Write a icon in display buffer.
|
|
||||||
Call display() to show display buffer.
|
|
||||||
Parameter
|
|
||||||
num: 0 - 28.
|
|
||||||
0 full screen 1 arrow_up 2 arrow_down 3 arrow_right
|
|
||||||
4 arrow_left 5 triangle_up 6 triangle_down 7 triangle_right
|
|
||||||
8 triangel_left 9 smile_face_1 10 smile_face_2 11 hearts
|
|
||||||
12 diamonds 13 clubs 14 spades 15 circle1
|
|
||||||
16 circle2 17 circle3 18 circle4 19 man
|
|
||||||
20 woman 21 musical_note_1 22 musical_note_2 23 snow
|
|
||||||
24 up_down 25 double_! 26 left_right 27 house
|
|
||||||
28 glasses
|
|
||||||
Return
|
|
||||||
Null.
|
|
||||||
*************************************************************/
|
|
||||||
void writeIcon(uint8_t num);
|
|
||||||
|
|
||||||
/*************************************************************
|
|
||||||
Description
|
|
||||||
Write a number(from -2147483648 to 2147483647) in display buffer.
|
|
||||||
Call display() to show display buffer.
|
|
||||||
Parameter
|
|
||||||
number: Set the number you want to display on LED matrix. Number(except 0-9)
|
|
||||||
will scroll horizontally, the shorter you set the ms_per_digit,
|
|
||||||
the faster it scrolls. The number range from -2147483648 to 2147483647, if
|
|
||||||
you want to display larger number, please use writeString().
|
|
||||||
ms_per_digit: Set the display time(ms) of per digit.
|
|
||||||
Return
|
|
||||||
Null.
|
|
||||||
*************************************************************/
|
|
||||||
void writeNumber(int32_t number, uint16_t ms_per_digit);
|
|
||||||
|
|
||||||
/*************************************************************
|
|
||||||
Description
|
|
||||||
Write a String in display buffer.
|
|
||||||
Call display() to show display buffer.
|
|
||||||
Parameter
|
|
||||||
s: A string. The string size should be less than (MAX_BIG_BUFFER_SIZE/8),
|
|
||||||
the excess part will be ignored.
|
|
||||||
ms_per_letter: Set the display time(ms) of per letter.
|
|
||||||
mode: ACTION_SCROLLING: If the size of string is more than 1, scroll the string on the matrix;
|
|
||||||
ACTION_SHIFT: If the size of string is more than 1, display the letter 1 by 1 on the matrix;
|
|
||||||
Return
|
|
||||||
Null.
|
|
||||||
*************************************************************/
|
|
||||||
void writeString(String s, uint16_t ms_per_letter, action_type_t mode);
|
|
||||||
|
|
||||||
/*************************************************************
|
|
||||||
Description
|
|
||||||
Write a picture in display buffer.
|
|
||||||
Call display() to show display buffer.
|
|
||||||
Parameter
|
|
||||||
pic: A pointer of a uint8_t picture array.
|
|
||||||
Return
|
|
||||||
Null.
|
|
||||||
*************************************************************/
|
|
||||||
void writeOnePicture(const uint8_t *pic);
|
|
||||||
|
|
||||||
/*************************************************************
|
|
||||||
Description
|
|
||||||
Write a picture in display buffer.
|
|
||||||
Call display() to show display buffer.
|
|
||||||
Parameter
|
|
||||||
pic: A uint64_t type 8x8 matrix picture, you can make it at
|
|
||||||
https://xantorohara.github.io/led-matrix-editor/#
|
|
||||||
Return
|
|
||||||
Null.
|
|
||||||
*************************************************************/
|
|
||||||
void writeOnePicture(const uint64_t pic);
|
|
||||||
|
|
||||||
/*************************************************************
|
|
||||||
Description
|
|
||||||
Write many pictures in display buffer.
|
|
||||||
Call display() to show display buffer.
|
|
||||||
Parameter
|
|
||||||
pic: A pointer
|
|
||||||
pic_number: The number of pictures, should be less than (MAX_BIG_BUFFER_SIZE/8),
|
|
||||||
the excess part will be ignored.
|
|
||||||
ms_per_pic: Set the display time(ms) of per picture.
|
|
||||||
mode: ACTION_SCROLLING: Scroll the pictures on the matrix;
|
|
||||||
ACTION_SHIFT: Display the pictures 1 by 1 on the matrix;
|
|
||||||
|
|
||||||
Return
|
|
||||||
Null.
|
|
||||||
*************************************************************/
|
|
||||||
void writePictures(const uint8_t *pic, uint8_t pic_number, uint16_t ms_per_pic, action_type_t mode);
|
|
||||||
void writePictures(const uint64_t *pic, uint8_t pic_number, uint16_t ms_per_pic, action_type_t mode);
|
|
||||||
|
|
||||||
private:
|
|
||||||
// Low1 High1 Low2 High2 ... Low8 High8
|
|
||||||
uint8_t _buffer[16];
|
|
||||||
uint8_t _big_buffer[MAX_BIG_BUFFER_SIZE];
|
|
||||||
uint16_t _cursor_start, _cursor_end, _cursor_steps;
|
|
||||||
uint16_t _ms;
|
|
||||||
orientation_type_t _orientation;
|
|
||||||
int8_t _offset_x, _offset_y;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif //__GROVE_LED_MATRIX_DRIVER_HT16K33__
|
|
@ -1,198 +0,0 @@
|
|||||||
/*
|
|
||||||
Seeed_Font.h
|
|
||||||
A font library for Grove - Grove - LED Matrix Driver(HT16K33 with 8x8 LED Matrix)
|
|
||||||
|
|
||||||
Copyright (c) 2018 seeed technology inc.
|
|
||||||
Website : www.seeed.cc
|
|
||||||
Author : Jerry Yip
|
|
||||||
Create Time: 2018-06
|
|
||||||
Version : 0.1
|
|
||||||
Change Log :
|
|
||||||
|
|
||||||
The MIT License (MIT)
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// start at ascii 32(dec), for example, '0' = ASCII[48-32]
|
|
||||||
const uint64_t ASCII[] = {
|
|
||||||
0x0000000000000000, // space
|
|
||||||
0x180018183c3c1800, // !
|
|
||||||
0x00000000286c6c00, // "
|
|
||||||
0x6c6cfe6cfe6c6c00, // #
|
|
||||||
0x103c403804781000, // $
|
|
||||||
0x60660c1830660600, // %
|
|
||||||
0xfc66a6143c663c00, // &
|
|
||||||
0x0000000c18181800, // '
|
|
||||||
0x6030181818306000, // (
|
|
||||||
0x060c1818180c0600, // )
|
|
||||||
0x006c38fe386c0000, // *
|
|
||||||
0x0010107c10100000, // +
|
|
||||||
0x060c0c0c00000000, // ,
|
|
||||||
0x0000003c00000000, // -
|
|
||||||
0x0606000000000000, // .
|
|
||||||
0x00060c1830600000, // /
|
|
||||||
0x1c2222222222221c, // 0
|
|
||||||
0x1c08080808080c08, // 1
|
|
||||||
0x3e0408102020221c, // 2
|
|
||||||
0x1c2220201820221c, // 3
|
|
||||||
0x20203e2224283020, // 4
|
|
||||||
0x1c2220201e02023e, // 5
|
|
||||||
0x1c2222221e02221c, // 6
|
|
||||||
0x040404081020203e, // 7
|
|
||||||
0x1c2222221c22221c, // 8
|
|
||||||
0x1c22203c2222221c, // 9
|
|
||||||
0x0018180018180000, // :
|
|
||||||
0x0c18180018180000, // ;
|
|
||||||
0x6030180c18306000, // <
|
|
||||||
0x00003c003c000000, // =
|
|
||||||
0x060c1830180c0600, // >
|
|
||||||
0x1800183860663c00, // ?
|
|
||||||
0x003c421a3a221c00, // @
|
|
||||||
0x0033333f33331e0c, // A
|
|
||||||
0x003f66663e66663f, // B
|
|
||||||
0x003c66030303663c, // C
|
|
||||||
0x001f36666666361f, // D
|
|
||||||
0x007f46161e16467f, // E
|
|
||||||
0x000f06161e16467f, // F
|
|
||||||
0x007c66730303663c, // G
|
|
||||||
0x003333333f333333, // H
|
|
||||||
0x001e0c0c0c0c0c1e, // I
|
|
||||||
0x001e333330303078, // J
|
|
||||||
0x006766361e366667, // K
|
|
||||||
0x007f66460606060f, // L
|
|
||||||
0x0063636b7f7f7763, // M
|
|
||||||
0x006363737b6f6763, // N
|
|
||||||
0x001c36636363361c, // O
|
|
||||||
0x000f06063e66663f, // P
|
|
||||||
0x00381e3b3333331e, // Q
|
|
||||||
0x006766363e66663f, // R
|
|
||||||
0x001e33380e07331e, // S
|
|
||||||
0x001e0c0c0c0c2d3f, // T
|
|
||||||
0x003f333333333333, // U
|
|
||||||
0x000c1e3333333333, // V
|
|
||||||
0x0063777f6b636363, // W
|
|
||||||
0x0063361c1c366363, // X
|
|
||||||
0x001e0c0c1e333333, // Y
|
|
||||||
0x007f664c1831637f, // Z
|
|
||||||
0x7818181818187800, // [
|
|
||||||
0x006030180c060000, // '\'
|
|
||||||
0x1e18181818181e00, // ]
|
|
||||||
0x0000008244281000, // ^
|
|
||||||
0x7e00000000000000, // _
|
|
||||||
0x0000000060303000, // `
|
|
||||||
0x006e333e301e0000, // a
|
|
||||||
0x003b66663e060607, // b
|
|
||||||
0x001e3303331e0000, // c
|
|
||||||
0x006e33333e303038, // d
|
|
||||||
0x001e033f331e0000, // e
|
|
||||||
0x000f06060f06361c, // f
|
|
||||||
0x1f303e33336e0000, // g
|
|
||||||
0x006766666e360607, // h
|
|
||||||
0x001e0c0c0c0e000c, // i
|
|
||||||
0x1e33333030300030, // j
|
|
||||||
0x0067361e36660607, // k
|
|
||||||
0x001e0c0c0c0c0c0e, // l
|
|
||||||
0x00636b7f7f330000, // m
|
|
||||||
0x00333333331f0000, // n
|
|
||||||
0x001e3333331e0000, // o
|
|
||||||
0x0f063e66663b0000, // p
|
|
||||||
0x78303e33336e0000, // q
|
|
||||||
0x000f06666e3b0000, // r
|
|
||||||
0x001f301e033e0000, // s
|
|
||||||
0x00182c0c0c3e0c08, // t
|
|
||||||
0x006e333333330000, // u
|
|
||||||
0x000c1e3333330000, // v
|
|
||||||
0x00367f7f6b630000, // w
|
|
||||||
0x0063361c36630000, // x
|
|
||||||
0x1f303e3333330000, // y
|
|
||||||
0x003f260c193f0000, // z
|
|
||||||
0x7018180c18187000, // {
|
|
||||||
0x0008080808080800, // |
|
|
||||||
0x0e18183018180e00, // }
|
|
||||||
0x000000365c000000 // ~
|
|
||||||
};
|
|
||||||
|
|
||||||
const uint64_t ICONS[] = {
|
|
||||||
0xffffffffffffffff, // 0 full screen
|
|
||||||
0x383838fe7c381000, // 1 arrow_up
|
|
||||||
0x10387cfe38383800, // 2 arrow_down
|
|
||||||
0x10307efe7e301000, // 3 arrow_right
|
|
||||||
0x1018fcfefc181000, // 4 arrow_left
|
|
||||||
0xfefe7c7c38381000, // 5 triangle_up
|
|
||||||
0x1038387c7cfefe00, // 6 triangle_down
|
|
||||||
0x061e7efe7e1e0600, // 7 triangle_right
|
|
||||||
0xc0f0fcfefcf0c000, // 8 triangel_left
|
|
||||||
0x7c92aa82aa827c00, // 9 smile_face_1
|
|
||||||
0x003c420000660000, // 10 smile_face_2
|
|
||||||
0x10387cfefeee4400, // 11 hearts
|
|
||||||
0x10387cfe7c381000, // 12 diamonds
|
|
||||||
0x381054fe54381000, // 13 clubs
|
|
||||||
0x38107cfe7c381000, // 14 spades
|
|
||||||
0x00387c7c7c380000, // 15 circle1
|
|
||||||
0xffc7838383c7ffff, // 16 circle2
|
|
||||||
0x0038444444380000, // 17 circle3
|
|
||||||
0xffc7bbbbbbc7ffff, // 18 circle4
|
|
||||||
0x0c12129ca0c0f000, // 19 man
|
|
||||||
0x38444438107c1000, // 20 woman
|
|
||||||
0x060e0c0808281800, // 21 musical_note_1
|
|
||||||
0x066eecc88898f000, // 22 musical_note_2
|
|
||||||
0x105438ee38541000, // 23 snow
|
|
||||||
0x1038541054381000, // 24 up_down
|
|
||||||
0x6666006666666600, // 25 double_!
|
|
||||||
0x002844fe44280000, // 26 left_right
|
|
||||||
0xfe8282c66c381000, // 27 house
|
|
||||||
0x002400e7a5bde700 // 28 glasses
|
|
||||||
};
|
|
||||||
|
|
||||||
const uint64_t BARS[] = {
|
|
||||||
0x0000000000000000,
|
|
||||||
0x1800000000000000,
|
|
||||||
0x3c00000000000000,
|
|
||||||
0x7e00000000000000,
|
|
||||||
0xff00000000000000,
|
|
||||||
0xff18000000000000,
|
|
||||||
0xff3c000000000000,
|
|
||||||
0xff7e000000000000,
|
|
||||||
0xffff000000000000,
|
|
||||||
0xffff180000000000,
|
|
||||||
0xffff3c0000000000,
|
|
||||||
0xffff7e0000000000,
|
|
||||||
0xffffff0000000000,
|
|
||||||
0xffffff1800000000,
|
|
||||||
0xffffff3c00000000,
|
|
||||||
0xffffff7e00000000,
|
|
||||||
0xffffffff00000000,
|
|
||||||
0xffffffff18000000,
|
|
||||||
0xffffffff3c000000,
|
|
||||||
0xffffffff7e000000,
|
|
||||||
0xffffffffff000000,
|
|
||||||
0xffffffffff180000,
|
|
||||||
0xffffffffff3c0000,
|
|
||||||
0xffffffffff7e0000,
|
|
||||||
0xffffffffffff0000,
|
|
||||||
0xffffffffffff1800,
|
|
||||||
0xffffffffffff3c00,
|
|
||||||
0xffffffffffff7e00,
|
|
||||||
0xffffffffffffff00,
|
|
||||||
0xffffffffffffff18,
|
|
||||||
0xffffffffffffff3c,
|
|
||||||
0xffffffffffffff7e,
|
|
||||||
0xffffffffffffffff
|
|
||||||
};
|
|
Binary file not shown.
@ -4,10 +4,3 @@
|
|||||||
- Wiki : https://wiki.seeedstudio.com/Grove-IMU_9DOF_v2.0/
|
- Wiki : https://wiki.seeedstudio.com/Grove-IMU_9DOF_v2.0/
|
||||||
- Forge : https://github.com/Seeed-Studio/Grove_IMU_9DOF
|
- Forge : https://github.com/Seeed-Studio/Grove_IMU_9DOF
|
||||||
- Licence : MIT
|
- Licence : MIT
|
||||||
|
|
||||||
### Grove_LED_Matrix_Driver_HT16K33 :
|
|
||||||
- Wiki : https://wiki.seeedstudio.com/Grove-Red_LED_Matrix_w_Driver
|
|
||||||
- Forge : https://github.com/Seeed-Studio/Grove_LED_Matrix_Driver_HT16K33
|
|
||||||
- Outil en ligne pour générer des caractères : https://xantorohara.github.io/led-matrix-editor/#
|
|
||||||
- Licence : MIT
|
|
||||||
|
|
||||||
|
Binary file not shown.
@ -57,12 +57,12 @@ def capteur(cont):
|
|||||||
# Lecture de la liaison série : programme Arduino : 4-labyrinthe-imu.ino
|
# Lecture de la liaison série : programme Arduino : 4-labyrinthe-imu.ino
|
||||||
serial_msg_in = str(serial_comm.readline())
|
serial_msg_in = str(serial_comm.readline())
|
||||||
|
|
||||||
# Mettre la bille à la position de départ avec une vitesse nulle
|
# # Mettre la bille à la position de départ avec une vitesse nulle
|
||||||
if serial_msg_in.find("start")>0:
|
# if serial_msg_in.find("start")>0:
|
||||||
if obj_bille['victoire'] or obj_bille['chute']:
|
# if obj_bille['victoire'] or obj_bille['chute']:
|
||||||
depart()
|
# depart()
|
||||||
|
|
||||||
# Roll et Pitch
|
# Roll et Pitch : copier la position du plateau réel
|
||||||
if serial_msg_in.find(",")>0:
|
if serial_msg_in.find(",")>0:
|
||||||
txt = serial_msg_in.split(',',2)
|
txt = serial_msg_in.split(',',2)
|
||||||
x_txt = txt[0][2:]
|
x_txt = txt[0][2:]
|
||||||
@ -98,35 +98,35 @@ def cycle(cont):
|
|||||||
obj = cont.owner # obj est l'objet associé au contrôleur donc 'Bille'
|
obj = cont.owner # obj est l'objet associé au contrôleur donc 'Bille'
|
||||||
obj['z']=obj.worldPosition.z # la propriété z est mis à jour avec la position globale en z de la bille
|
obj['z']=obj.worldPosition.z # la propriété z est mis à jour avec la position globale en z de la bille
|
||||||
|
|
||||||
# Écriture de la position de la bille sur la liaison série
|
# # Écriture de la position de la bille sur la liaison série
|
||||||
if obj['victoire']==False and obj['chute']==False:
|
# if obj['victoire']==False and obj['chute']==False:
|
||||||
# obj['x'] = obj.worldPosition.x # de -3.5 à 3.5
|
# # obj['x'] = obj.worldPosition.x # de -3.5 à 3.5
|
||||||
# obj['y'] = obj.worldPosition.y # de 3.5 à -3.5
|
# # obj['y'] = obj.worldPosition.y # de 3.5 à -3.5
|
||||||
obj['Lx']=-1*round(obj.worldPosition.x-3.5) # de 7 à 0
|
# obj['Lx']=-1*round(obj.worldPosition.x-3.5) # de 7 à 0
|
||||||
if obj['Lx']<0: obj['Lx']=0
|
# if obj['Lx']<0: obj['Lx']=0
|
||||||
if obj['Lx']>7: obj['Lx']=7
|
# if obj['Lx']>7: obj['Lx']=7
|
||||||
obj['Ly']=-1*round(obj.worldPosition.y-3.5) # de 0 à 7
|
# obj['Ly']=-1*round(obj.worldPosition.y-3.5) # de 0 à 7
|
||||||
if obj['Ly']<0: obj['Ly']=0
|
# if obj['Ly']<0: obj['Ly']=0
|
||||||
if obj['Ly']>7: obj['Ly']=7
|
# if obj['Ly']>7: obj['Ly']=7
|
||||||
serial_msg_out = str(obj['Lx'])+str(obj['Ly'])+"\n"
|
# serial_msg_out = str(obj['Lx'])+str(obj['Ly'])+"\n"
|
||||||
serial_comm.write(serial_msg_out.encode())
|
# serial_comm.write(serial_msg_out.encode())
|
||||||
|
|
||||||
# Si l'altitude de bille < -10 et pas de victoire -> chute
|
# # Si l'altitude de bille < -10 et pas de victoire -> chute
|
||||||
if obj['z'] < -10 and obj['victoire'] == False :
|
# if obj['z'] < -10 and obj['victoire'] == False :
|
||||||
|
|
||||||
# Afficher image de chute sur la matrice de leds
|
# # Afficher image de chute sur la matrice de leds
|
||||||
serial_msg_out = "91\n"
|
# serial_msg_out = "91\n"
|
||||||
serial_comm.write(serial_msg_out.encode())
|
# serial_comm.write(serial_msg_out.encode())
|
||||||
obj['chute'] = True
|
# obj['chute'] = True
|
||||||
|
|
||||||
# Départ de la bille
|
# Départ de la bille
|
||||||
def depart():
|
def depart():
|
||||||
obj_bille = scene.objects['Bille']
|
obj_bille = scene.objects['Bille']
|
||||||
obj_plateau = scene.objects['Plateau']
|
obj_plateau = scene.objects['Plateau']
|
||||||
|
|
||||||
# Replacement du plateau (tous les angles à 0 en plusieurs fois)
|
# # Replacement du plateau (tous les angles à 0 en plusieurs fois)
|
||||||
while obj_plateau.worldOrientation.to_euler().x != 0 and obj_plateau.worldOrientation.to_euler().y !=0 and obj_plateau.worldOrientation.to_euler().z !=0 :
|
# while obj_plateau.worldOrientation.to_euler().x != 0 and obj_plateau.worldOrientation.to_euler().y !=0 and obj_plateau.worldOrientation.to_euler().z !=0 :
|
||||||
obj_plateau.applyRotation((-obj_plateau.worldOrientation.to_euler().x, -obj_plateau.worldOrientation.to_euler().y, -obj_plateau.worldOrientation.to_euler().z), False)
|
# obj_plateau.applyRotation((-obj_plateau.worldOrientation.to_euler().x, -obj_plateau.worldOrientation.to_euler().y, -obj_plateau.worldOrientation.to_euler().z), False)
|
||||||
|
|
||||||
# Mettre la bille à la position de départ avec une vitesse nulle
|
# Mettre la bille à la position de départ avec une vitesse nulle
|
||||||
obj_bille.worldLinearVelocity=(0, 0, 0)
|
obj_bille.worldLinearVelocity=(0, 0, 0)
|
||||||
@ -140,10 +140,10 @@ def depart():
|
|||||||
# Victoire (collision de la bille avec l'arrivée)
|
# Victoire (collision de la bille avec l'arrivée)
|
||||||
def victoire(cont):
|
def victoire(cont):
|
||||||
|
|
||||||
# Afficher image de victoire sur la matrice de leds
|
# # Afficher image de victoire sur la matrice de leds
|
||||||
serial_msg_out = "92\n"
|
# serial_msg_out = "92\n"
|
||||||
serial_comm.write(serial_msg_out.encode())
|
# serial_comm.write(serial_msg_out.encode())
|
||||||
scene.objects['Bille']['victoire']=True
|
# scene.objects['Bille']['victoire']=True
|
||||||
|
|
||||||
# Animation du Panneau victoire
|
# Animation du Panneau victoire
|
||||||
scene.objects['Panneau victoire'].setVisible(True,True) # Afficher le panneau de la victoire
|
scene.objects['Panneau victoire'].setVisible(True,True) # Afficher le panneau de la victoire
|
||||||
|
34302
labyrinthe/6-jumeaux/impression3d/attache-cables.stl
Executable file
34302
labyrinthe/6-jumeaux/impression3d/attache-cables.stl
Executable file
File diff suppressed because it is too large
Load Diff
18678
labyrinthe/6-jumeaux/impression3d/attache-domino.stl
Executable file
18678
labyrinthe/6-jumeaux/impression3d/attache-domino.stl
Executable file
File diff suppressed because it is too large
Load Diff
34078
labyrinthe/6-jumeaux/impression3d/attache-plaque.stl
Executable file
34078
labyrinthe/6-jumeaux/impression3d/attache-plaque.stl
Executable file
File diff suppressed because it is too large
Load Diff
15458
labyrinthe/6-jumeaux/impression3d/cam-mount-1.stl
Executable file
15458
labyrinthe/6-jumeaux/impression3d/cam-mount-1.stl
Executable file
File diff suppressed because it is too large
Load Diff
38768
labyrinthe/6-jumeaux/impression3d/cam-mount-2.stl
Executable file
38768
labyrinthe/6-jumeaux/impression3d/cam-mount-2.stl
Executable file
File diff suppressed because it is too large
Load Diff
3558
labyrinthe/6-jumeaux/impression3d/cam-pied-joint-ouvert.stl
Executable file
3558
labyrinthe/6-jumeaux/impression3d/cam-pied-joint-ouvert.stl
Executable file
File diff suppressed because it is too large
Load Diff
22402
labyrinthe/6-jumeaux/impression3d/cam-pied-partie1.stl
Executable file
22402
labyrinthe/6-jumeaux/impression3d/cam-pied-partie1.stl
Executable file
File diff suppressed because it is too large
Load Diff
1150
labyrinthe/6-jumeaux/impression3d/cam-pied-partie2.stl
Executable file
1150
labyrinthe/6-jumeaux/impression3d/cam-pied-partie2.stl
Executable file
File diff suppressed because it is too large
Load Diff
47378
labyrinthe/6-jumeaux/impression3d/cam-pied-partie3.stl
Executable file
47378
labyrinthe/6-jumeaux/impression3d/cam-pied-partie3.stl
Executable file
File diff suppressed because it is too large
Load Diff
47168
labyrinthe/6-jumeaux/impression3d/cam-pied-partie4.stl
Executable file
47168
labyrinthe/6-jumeaux/impression3d/cam-pied-partie4.stl
Executable file
File diff suppressed because it is too large
Load Diff
48260
labyrinthe/6-jumeaux/impression3d/cam-pied-partie5.stl
Executable file
48260
labyrinthe/6-jumeaux/impression3d/cam-pied-partie5.stl
Executable file
File diff suppressed because it is too large
Load Diff
BIN
labyrinthe/6-jumeaux/impression3d/entretoise-m3.stl
Normal file
BIN
labyrinthe/6-jumeaux/impression3d/entretoise-m3.stl
Normal file
Binary file not shown.
19854
labyrinthe/6-jumeaux/impression3d/poche-bille-9mm.stl
Executable file
19854
labyrinthe/6-jumeaux/impression3d/poche-bille-9mm.stl
Executable file
File diff suppressed because it is too large
Load Diff
BIN
labyrinthe/6-jumeaux/impression3d/poche.stl
Normal file → Executable file
BIN
labyrinthe/6-jumeaux/impression3d/poche.stl
Normal file → Executable file
Binary file not shown.
Binary file not shown.
@ -121,18 +121,6 @@ void loop() {
|
|||||||
pitch_deg = pitch*57.3;
|
pitch_deg = pitch*57.3;
|
||||||
pitch_txt = String(pitch_deg);
|
pitch_txt = String(pitch_deg);
|
||||||
|
|
||||||
/*****
|
|
||||||
* Affiche les angles de roulie et de tangage
|
|
||||||
*****/
|
|
||||||
|
|
||||||
/* if (auto_horizontal) */
|
|
||||||
/* { */
|
|
||||||
/* Serial.print(roll_txt); */
|
|
||||||
/* Serial.print(","); */
|
|
||||||
/* Serial.print(pitch_txt); */
|
|
||||||
/* Serial.println(); */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
/*****
|
/*****
|
||||||
* Mouvement manuel : Axe x
|
* Mouvement manuel : Axe x
|
||||||
*****/
|
*****/
|
||||||
@ -263,7 +251,7 @@ void loop() {
|
|||||||
digitalWrite(led_pin, HIGH); // Led
|
digitalWrite(led_pin, HIGH); // Led
|
||||||
auto_horizontal_mvt = false;
|
auto_horizontal_mvt = false;
|
||||||
|
|
||||||
// Mouvemeent
|
// Mouvement
|
||||||
if ((roll_deg < -1) or (roll_deg > 1) or (pitch_deg < -1) or (pitch_deg > 1))
|
if ((roll_deg < -1) or (roll_deg > 1) or (pitch_deg < -1) or (pitch_deg > 1))
|
||||||
auto_horizontal_mvt = true;
|
auto_horizontal_mvt = true;
|
||||||
if (roll_deg < -1)
|
if (roll_deg < -1)
|
||||||
|
Loading…
Reference in New Issue
Block a user