development environments raspberry pi ® saman amighi 04/2014 ® raspberry pi foundation

12
Development Environments Raspberry Pi ® Saman Amighi 04/2014 ® Raspberry Pi Foundation

Upload: kristian-ellis

Post on 01-Jan-2016

226 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Development Environments Raspberry Pi ® Saman Amighi 04/2014 ® Raspberry Pi Foundation

Development Environments

Raspberry Pi ®

Saman Amighi 04/2014

® Raspberry Pi Foundation

Page 2: 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

Page 3: Development Environments Raspberry Pi ® Saman Amighi 04/2014 ® Raspberry Pi Foundation

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

Page 4: Development Environments Raspberry Pi ® Saman Amighi 04/2014 ® Raspberry Pi Foundation

Raspberry PiGeneral Purpose Input

Output (GPIO)Key Pins

1 – 3.3 V2 – 5 V6 – Ground7 – GPIO4*13 – GPIO21/27

Page 5: Development Environments Raspberry Pi ® Saman Amighi 04/2014 ® Raspberry Pi Foundation

Raspberry PiFirst steps

Purchase Raspberry Pi

Purchase Components

Create SD card

Boot up initial Image

Login

Page 6: Development Environments Raspberry Pi ® Saman Amighi 04/2014 ® Raspberry Pi Foundation

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

Page 7: Development Environments Raspberry Pi ® Saman Amighi 04/2014 ® Raspberry Pi Foundation

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

Page 8: Development Environments Raspberry Pi ® Saman Amighi 04/2014 ® Raspberry Pi Foundation

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

Page 9: Development Environments Raspberry Pi ® Saman Amighi 04/2014 ® Raspberry Pi Foundation

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;}

Page 10: Development Environments Raspberry Pi ® Saman Amighi 04/2014 ® Raspberry Pi Foundation

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;}

Page 11: Development Environments Raspberry Pi ® Saman Amighi 04/2014 ® Raspberry Pi Foundation

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)

Page 12: Development Environments Raspberry Pi ® Saman Amighi 04/2014 ® Raspberry Pi Foundation

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'