Окт 272016
 

987654321

  • 10DOF modules (three-axis gyroscope + triaxial accelerometer and three-axis magnetic field + atmospheric pressure)
  • Means of communication: IIC Communication protocol(fully compatible with 3-5V system containing LLC circuit)
  • Acceleration,Gyroscope and magnetometer
  • chip:MPU6050+HMC5883+BMP180
  • power supply :3.3V-5V
  • size:2.2cmx1.7cm

qwertyuiop 1234567890

Описание.

Для включения компаса HMC5883L нужно следующие.
// Bypass Mode
Wire.beginTransmission(0x68); // Address of MPU5060
Wire.write(0x37);
Wire.write(0x02);
Wire.endTransmission();

Wire.beginTransmission(0x68);
Wire.write(0x6A);
Wire.write(0x00);
Wire.endTransmission();

// Disable Sleep Mode
Wire.beginTransmission(0x68);
Wire.write(0x6B);
Wire.write(0x00);
Wire.endTransmission();

Июл 082016
 

 

2560-arduino-home-made

Вот решил Arduino собрать на ATmega2560, вот что получилось.

p.s. Плата переходник для подключения WG12864B

U8GLIB_KS0108_128 u8g(22,23,24,25,26,27,28,29,34,30,39,33,32,31);

// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs1=14, cs2=15,di=17,rw=16,rst=31

Тест программка.

#include <openGLCD.h>

void setup()
{
  GLCD.Init();
  GLCD.SelectFont(System5x7);
  GLCD.ClearScreen();

  pinMode(A15, OUTPUT);
  pinMode(44, OUTPUT);
  digitalWrite(44, HIGH);    
  digitalWrite(A15,HIGH);
}

byte pos = 0;
byte r;
void loop()
{
  while(1) {
    GLCD.ClearScreen();

    for(byte x=0;x<11;x++) {
      r = random(1,63);
      if (pos==0) {
        Bar(pos,0,10,r);
      }
      else {
        Bar(pos+(x*2),0,10,r);
      }
      pos=pos+10;
    }
    delay(200);
    pos =0;
  }

}

void Bar(int x,int y, int w, int h) {
  GLCD.FillRect(x,63-h,w,h,BLACK);
}
Апр 292016
 
import pygame
import os
from time import sleep
import RPi.GPIO as GPIO

#Note #21 changed to #27 for rev2 Pi
button_map = {23:(255,0,0), 22:(0,255,0), 21:(0,0,255), 18:(0,0,0)}

#Setup the GPIOs as inputs with Pull Ups since the buttons are connected to GND
GPIO.setmode(GPIO.BCM)
for k in button_map.keys():
    GPIO.setup(k, GPIO.IN, pull_up_down=GPIO.PUD_UP)

#Colours
WHITE = (255,255,255)

os.putenv('SDL_FBDEV', '/dev/fb1')
pygame.init()
pygame.mouse.set_visible(False)
lcd = pygame.display.set_mode((320, 240))
lcd.fill((0,0,0))
pygame.display.update()

font_big = pygame.font.Font(None, 100)

while True:
    # Scan the buttons
    for (k,v) in button_map.items():
        if GPIO.input(k) == False:
            lcd.fill(v)
            text_surface = font_big.render('%d'%k, True, WHITE)
            rect = text_surface.get_rect(center=(160,120))
            lcd.blit(text_surface, rect)
            pygame.display.update()
    sleep(0.1)

TouchScreen

import pygame
from pygame.locals import *
import os
from time import sleep
import RPi.GPIO as GPIO

#Setup the GPIOs as outputs - only 4 and 17 are available
GPIO.setmode(GPIO.BCM)
GPIO.setup(4, GPIO.OUT)
GPIO.setup(17, GPIO.OUT)

#Colours
WHITE = (255,255,255)

os.putenv('SDL_FBDEV', '/dev/fb1')
os.putenv('SDL_MOUSEDRV', 'TSLIB')
os.putenv('SDL_MOUSEDEV', '/dev/input/touchscreen')

pygame.init()
pygame.mouse.set_visible(False)
lcd = pygame.display.set_mode((320, 240))
lcd.fill((0,0,0))
pygame.display.update()

font_big = pygame.font.Font(None, 50)

touch_buttons = {'17 on':(80,60), '4 on':(240,60), '17 off':(80,180), '4 off':(240,180)}

for k,v in touch_buttons.items():
    text_surface = font_big.render('%s'%k, True, WHITE)
    rect = text_surface.get_rect(center=v)
    lcd.blit(text_surface, rect)

pygame.display.update()

while True:
    # Scan touchscreen events
    for event in pygame.event.get():
        if(event.type is MOUSEBUTTONDOWN):
            pos = pygame.mouse.get_pos()
            print pos
        elif(event.type is MOUSEBUTTONUP):
            pos = pygame.mouse.get_pos()
            print pos
            #Find which quarter of the screen we're in
            x,y = pos
            if y < 120:
                if x < 160:
                    GPIO.output(17, False)
                else:
                    GPIO.output(4, False)
            else:
                if x < 160:
                    GPIO.output(17, True)
                else:
                    GPIO.output(4, True)
    sleep(0.1)