Date post: | 01-Jan-2016 |
Category: |
Documents |
Upload: | kristian-ellis |
View: | 225 times |
Download: | 1 times |
Development Environments
Raspberry Pi ®
Saman Amighi 04/2014
® Raspberry Pi Foundation
Raspberry PiRaspberry Pi
Created by the Raspberry Pi Foundation
Built to be an educational tool
Credit Card size computer
Linux Based
Can be powered up with existing power supplies or batteries
Raspberry Pi
Key PartsPorts
• USB (1/2)• Keyboard• Mouse
• Power (microUSB)
• SD Card• HDMI or TV
Video • Network/LAN
(100)• Other
• GPIO pins• Audio Jack• Status
LEDs
Raspberry PiGeneral Purpose Input
Output (GPIO)Key Pins
1 – 3.3 V2 – 5 V6 – Ground7 – GPIO4*13 – GPIO21/27
Raspberry PiFirst steps
Purchase Raspberry Pi
Purchase Components
Create SD card
Boot up initial Image
Login
Next StepsDecide on a
projectWhich project do you want to work on?Electronics – 3 hours - $50
Media Center – 3-5 hours - $30
Linux box with 100% up time – 1 hours - $0
Printer Server (CUPS) – 1 hours - $0
NAS – 3 hours - $100
Laptop (Atrix Lapdock) – 3 hours - $100
Development Enviroment
Decide on a Development EnviromentWhere?
Work on the Raspberry PI
Work on your own Computer
How?Which editor to use
Locally - VI, EMACS, NANO, etc.
Remotely - Windows- Notepad, Mac – TextWrangler
Required native SFTP and backups
Development Environment (cont’d)
Decide on a Development Environment (cont’d)
Programming LanguageC/C++
Python
Shell Scripts (+Cron)
PHP
Etc
Native Compilers/Processors GCC++
Python
PHP
Non-NativeIno/Arduino
Ruby
Language Examples
C/C++C++ - Compiled Languagecase sensitive
Difficult to work with strings
Very specific on variable types
Code char myString[10];
int iMyInt;
strcpy(myString,”Hello”);
Int myFunction(int ilocalInteger) { return ilocalInteger+1;}
C++ Example
bool MPU9150::begin(mpu9150_gyro_range_t g_rng, mpu9150_accel_range_t a_rng, byte addr) {
Wire.begin(); address_ = addr; // Make sure the correct device is actually connected if (read8(MPU9150_WHO_AM_I) != MPU9150_ID) { return false; } // Set the gyro range write8((byte)MPU9150_GYRO_CONFIG, (byte)g_rng << 3); // Set the accel range write8((byte)MPU9150_ACCEL_CONFIG, (byte)a_rng << 3); // Set the clock source and take the device out of sleep mode write8((byte)MPU9150_PWR_MGMT_1, 0x02);
return true;}
Language ExamplesPythonPython – Interpretive Language
Case sensitive
Indentation heavy (instead of using {} or terminators)
Loose on type definitions ( 1 = “1”)
Can be run interactively python func1.py OR python and use command line
Print “Hello World”
a = 5
mult(a)
Python ExampleCommand Line
$ python -c 'print "Hello World!"’
Codeimport re
for test_string in ['555-1212', 'ILL-EGAL']:
if re.match(r'^\d{3}-\d{4}$', test_string):
print test_string, 'is a valid US local phone number'
else:
print test_string, 'rejected'