From 6629c2c6def6230e1b2b98721523ed66fc72d1e3 Mon Sep 17 00:00:00 2001 From: Dogus Cendek Date: Thu, 8 Jun 2023 11:46:35 +0300 Subject: [PATCH 01/18] Update URL infos Update URL infos --- package_cezerio_blocks_index.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package_cezerio_blocks_index.json b/package_cezerio_blocks_index.json index d5b3899..51fd7d4 100644 --- a/package_cezerio_blocks_index.json +++ b/package_cezerio_blocks_index.json @@ -3,9 +3,9 @@ { "name": "cezerio Blocks", "maintainer": "cezerio", - "websiteUrl": "http://www.cezerio.com/", - "Url": "https://downloads.arduino.cc/packages/package_index.tar.bz2", - "email": "packages@arduino.cc", + "websiteUrl": "https://github.com/cezer-io", + "Url": "https://github.com/cezer-io/cezerio-blocks-arduino", + "email": "hello@cezerio.com", "platforms": [ { "name": "cezerio Blocks", @@ -13,8 +13,8 @@ "version": "1.0.0", "deprecated": false, "category": "Arduino", - "url": "http://downloads.arduino.cc/cores/staging/avr-1.8.6.tar.bz2", - "archiveFileName": "avr-1.8.6.tar.bz2", + "url": "https://github.com/cezer-io/cezerio-blocks-arduino/releases/download/1.0.0/cezerioblocks-1.0.0.zip", + "archiveFileName": "cezerioblocks-1.0.0.zip", "checksum": "SHA-256:f4b0f6a78ad594b3e72acec9441f1a5e92c6d554208a803555086004f2115d5d", "size": "8127379", "boards": [ From 27616c36e98cacfe7e22d123cd204123eaa8792d Mon Sep 17 00:00:00 2001 From: Dogus Cendek Date: Thu, 8 Jun 2023 12:13:06 +0300 Subject: [PATCH 02/18] Update package_cezerio_blocks_index.json --- package_cezerio_blocks_index.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package_cezerio_blocks_index.json b/package_cezerio_blocks_index.json index 51fd7d4..40aabd5 100644 --- a/package_cezerio_blocks_index.json +++ b/package_cezerio_blocks_index.json @@ -4,7 +4,6 @@ "name": "cezerio Blocks", "maintainer": "cezerio", "websiteUrl": "https://github.com/cezer-io", - "Url": "https://github.com/cezer-io/cezerio-blocks-arduino", "email": "hello@cezerio.com", "platforms": [ { From 9ca1d76cfb016bccb10ea77b86809bb905d525ca Mon Sep 17 00:00:00 2001 From: Dogus Cendek Date: Thu, 8 Jun 2023 12:29:54 +0300 Subject: [PATCH 03/18] Update README.md --- README.md | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 42a1f04..f7d1d64 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,15 @@ -# Arduino AVR Boards +# cezerio blocks Arduino Core -[![Check Arduino status](https://github.com/arduino/ArduinoCore-avr/actions/workflows/check-arduino.yml/badge.svg)](https://github.com/arduino/ArduinoCore-avr/actions/workflows/check-arduino.yml) -[![Compile Examples status](https://github.com/arduino/ArduinoCore-avr/actions/workflows/compile-platform-examples.yml/badge.svg)](https://github.com/arduino/ArduinoCore-avr/actions/workflows/compile-platform-examples.yml) -[![Spell Check status](https://github.com/arduino/ArduinoCore-avr/actions/workflows/spell-check.yml/badge.svg)](https://github.com/arduino/ArduinoCore-avr/actions/workflows/spell-check.yml) +cezerio blocks, designed and manufactured in Turkey, have a powerful MCU and unique design. It allows the users in all levels (beginners to professionals) to build and code own robots in the fields of Electronics, Internet of Things (IoT) and Artificial Intelligence (AI). -This repository contains the source code and configuration files of the Arduino AVR Boards -[platform](https://arduino.github.io/arduino-cli/latest/platform-specification/). +### Installation Instructions +JSON index file: `https://raw.githubusercontent.com/cezer-io/cezerio-blocks-arduino/main/package_cezerio_blocks_index.json` +- Install the latest [Arduino IDE](https://www.arduino.cc/en/software). +- Start Arduino IDE and open Preferences window. +- Copy the JSON index file link above into Additional Board Manager URLs field. +- Open Boards Manager from Tools > Board menu and install "cezerio blocks". +- Select "cezerio blocks" from Tools > Board menu after installation. + +### Development Status + + [![Release Version](https://img.shields.io/github/v/release/cezer-io/cezerio-blocks-arduino?color=880414)](https://github.com/cezer-io/cezerio-blocks-arduino/releases/latest/) [![Release Date](https://img.shields.io/github/release-date/cezer-io/cezerio-blocks-arduino?color=487c17)](https://github.com/cezer-io/cezerio-blocks-arduino/releases/latest/) [![Downloads](https://img.shields.io/github/downloads/cezer-io/cezerio-blocks-arduino/latest/total?color=167cc9)](https://github.com/cezer-io/cezerio-blocks-arduino/releases/latest/) [![Downloads](https://img.shields.io/github/downloads/cezer-io/cezerio-blocks-arduino/total?color=167cc9)](https://github.com/cezer-io/cezerio-blocks-arduino/releases/latest/) From 2ee7193297d7128c95959563a378f2ed959c8680 Mon Sep 17 00:00:00 2001 From: Dogus Cendek Date: Thu, 8 Jun 2023 14:08:16 +0300 Subject: [PATCH 04/18] Update package_cezerio_blocks_index.json --- package_cezerio_blocks_index.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package_cezerio_blocks_index.json b/package_cezerio_blocks_index.json index 40aabd5..37f6f48 100644 --- a/package_cezerio_blocks_index.json +++ b/package_cezerio_blocks_index.json @@ -22,7 +22,7 @@ } ], "help": { - "online": "http://www.arduino.cc/en/Reference/HomePage" + "online": "https://github.com/cezer-io" }, "toolsDependencies": [ { @@ -139,7 +139,7 @@ } ], "help": { - "online": "http://www.arduino.cc/en/Reference/HomePage" + "online": "https://github.com/cezer-io" } } ], From bc7a89c314ca7534ff8f4c0b2ed5bd58e418b52d Mon Sep 17 00:00:00 2001 From: Dogus Cendek Date: Thu, 8 Jun 2023 14:59:47 +0300 Subject: [PATCH 05/18] Update package_cezerio_blocks_index.json --- package_cezerio_blocks_index.json | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/package_cezerio_blocks_index.json b/package_cezerio_blocks_index.json index 37f6f48..b3d09ff 100644 --- a/package_cezerio_blocks_index.json +++ b/package_cezerio_blocks_index.json @@ -5,6 +5,9 @@ "maintainer": "cezerio", "websiteUrl": "https://github.com/cezer-io", "email": "hello@cezerio.com", + "help": { + "online": "https://github.com/cezer-io" + }, "platforms": [ { "name": "cezerio Blocks", @@ -16,14 +19,14 @@ "archiveFileName": "cezerioblocks-1.0.0.zip", "checksum": "SHA-256:f4b0f6a78ad594b3e72acec9441f1a5e92c6d554208a803555086004f2115d5d", "size": "8127379", + "help": { + "online": "" + }, "boards": [ { "name": "cezerio Blocks" } ], - "help": { - "online": "https://github.com/cezer-io" - }, "toolsDependencies": [ { "packager": "arduino", @@ -137,11 +140,7 @@ } ] } - ], - "help": { - "online": "https://github.com/cezer-io" - } + ] } - ], - "IsTrusted": true + ] } From 7262d7fde91bfde2909257ac0ccc279825d820a2 Mon Sep 17 00:00:00 2001 From: Dogus Cendek Date: Thu, 8 Jun 2023 15:45:05 +0300 Subject: [PATCH 06/18] Update package_cezerio_blocks_index.json --- package_cezerio_blocks_index.json | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/package_cezerio_blocks_index.json b/package_cezerio_blocks_index.json index b3d09ff..5af9c0e 100644 --- a/package_cezerio_blocks_index.json +++ b/package_cezerio_blocks_index.json @@ -27,6 +27,9 @@ "name": "cezerio Blocks" } ], + "help": { + "online": "https://github.com/cezer-io" + }, "toolsDependencies": [ { "packager": "arduino", @@ -140,7 +143,11 @@ } ] } - ] + ], + "help": { + "online": "https://github.com/cezer-io" + } } - ] + ], + "IsTrusted": true } From 2be787431739a33d24124e474c7a39c29863fcbb Mon Sep 17 00:00:00 2001 From: Dogus Cendek Date: Wed, 14 Jun 2023 15:01:54 +0300 Subject: [PATCH 07/18] Update package_cezerio_blocks_index.json --- package_cezerio_blocks_index.json | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/package_cezerio_blocks_index.json b/package_cezerio_blocks_index.json index 5af9c0e..3167566 100644 --- a/package_cezerio_blocks_index.json +++ b/package_cezerio_blocks_index.json @@ -5,16 +5,13 @@ "maintainer": "cezerio", "websiteUrl": "https://github.com/cezer-io", "email": "hello@cezerio.com", - "help": { - "online": "https://github.com/cezer-io" - }, "platforms": [ { "name": "cezerio Blocks", "architecture": "avr", "version": "1.0.0", "deprecated": false, - "category": "Arduino", + "category": "Contributed", "url": "https://github.com/cezer-io/cezerio-blocks-arduino/releases/download/1.0.0/cezerioblocks-1.0.0.zip", "archiveFileName": "cezerioblocks-1.0.0.zip", "checksum": "SHA-256:f4b0f6a78ad594b3e72acec9441f1a5e92c6d554208a803555086004f2115d5d", From 8fd8f89139c696c444b50ae60f3778832dfdcdb5 Mon Sep 17 00:00:00 2001 From: Dogus Cendek Date: Wed, 14 Jun 2023 16:22:31 +0300 Subject: [PATCH 08/18] Update package_cezerio_blocks_index.json --- package_cezerio_blocks_index.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package_cezerio_blocks_index.json b/package_cezerio_blocks_index.json index 3167566..7295252 100644 --- a/package_cezerio_blocks_index.json +++ b/package_cezerio_blocks_index.json @@ -12,10 +12,10 @@ "version": "1.0.0", "deprecated": false, "category": "Contributed", - "url": "https://github.com/cezer-io/cezerio-blocks-arduino/releases/download/1.0.0/cezerioblocks-1.0.0.zip", - "archiveFileName": "cezerioblocks-1.0.0.zip", - "checksum": "SHA-256:f4b0f6a78ad594b3e72acec9441f1a5e92c6d554208a803555086004f2115d5d", - "size": "8127379", + "url": "https://github.com/cezer-io/cezerio-blocks-arduino/archive/refs/tags/1.0.0.tar.gz", + "archiveFileName": "1.0.0.tar.gz", + "checksum": "SHA-256:03a8cea8e82182b028b9d9a70f29b26f5add2872808fe3c5a2eb319ed86ecab3", + "size": "7600100", "help": { "online": "" }, From b1f2c9a2ab5fd356bf2658eef70abbe2317295d3 Mon Sep 17 00:00:00 2001 From: Dogus Cendek Date: Wed, 14 Jun 2023 16:52:46 +0300 Subject: [PATCH 09/18] Update package_cezerio_blocks_index.json --- package_cezerio_blocks_index.json | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/package_cezerio_blocks_index.json b/package_cezerio_blocks_index.json index 7295252..4e77cb4 100644 --- a/package_cezerio_blocks_index.json +++ b/package_cezerio_blocks_index.json @@ -10,7 +10,6 @@ "name": "cezerio Blocks", "architecture": "avr", "version": "1.0.0", - "deprecated": false, "category": "Contributed", "url": "https://github.com/cezer-io/cezerio-blocks-arduino/archive/refs/tags/1.0.0.tar.gz", "archiveFileName": "1.0.0.tar.gz", @@ -140,11 +139,7 @@ } ] } - ], - "help": { - "online": "https://github.com/cezer-io" - } + ] } - ], - "IsTrusted": true + ] } From 319e8b1aeb5ab74e4e5cd15d918e62f4ebe9c202 Mon Sep 17 00:00:00 2001 From: Dogus Cendek Date: Wed, 14 Jun 2023 19:13:25 +0300 Subject: [PATCH 10/18] Update and Add New Examples Update and Add New Examples --- .../{ => Bluetooth}/Chariot/Chariot.ino | 50 ++++++++--------- .../{ => Bluetooth}/Flying_Car/Flying_Car.ino | 52 +++++++++--------- .../{ => Bluetooth}/Roller/Roller.ino | 44 +++++++-------- .../SendReceiveBluetooth.ino | 51 +++++------------ .../examples/{ => Bluetooth}/Truck/Truck.ino | 50 ++++++++--------- .../{ => Bluetooth}/Windmill/Windmill.ino | 39 ++++++------- .../CezerioBlocks/examples/Level/Level.ino | 37 +++++++++++++ .../MotionDetector/MotionDetector.ino | 46 ++++++++++++++++ .../examples/NightLamb/NightLamb.ino | 45 +++++++++++++++ .../CezerioBlocks/examples/Runner/Runner.ino | 47 ++++------------ .../examples/SendReceive/SendReceive.ino | 35 +++--------- .../examples/Sensormatic/Sensormatic.ino | 55 +++++-------------- .../examples/ShakyMic/ShakyMic.ino | 48 ++++++++++++++++ 13 files changed, 341 insertions(+), 258 deletions(-) rename libraries/CezerioBlocks/examples/{ => Bluetooth}/Chariot/Chariot.ino (94%) rename libraries/CezerioBlocks/examples/{ => Bluetooth}/Flying_Car/Flying_Car.ino (94%) rename libraries/CezerioBlocks/examples/{ => Bluetooth}/Roller/Roller.ino (93%) rename libraries/CezerioBlocks/examples/{ => Bluetooth}/SendReceiveBluetooth/SendReceiveBluetooth.ino (77%) rename libraries/CezerioBlocks/examples/{ => Bluetooth}/Truck/Truck.ino (96%) rename libraries/CezerioBlocks/examples/{ => Bluetooth}/Windmill/Windmill.ino (87%) create mode 100644 libraries/CezerioBlocks/examples/Level/Level.ino create mode 100644 libraries/CezerioBlocks/examples/MotionDetector/MotionDetector.ino create mode 100644 libraries/CezerioBlocks/examples/NightLamb/NightLamb.ino create mode 100644 libraries/CezerioBlocks/examples/ShakyMic/ShakyMic.ino diff --git a/libraries/CezerioBlocks/examples/Chariot/Chariot.ino b/libraries/CezerioBlocks/examples/Bluetooth/Chariot/Chariot.ino similarity index 94% rename from libraries/CezerioBlocks/examples/Chariot/Chariot.ino rename to libraries/CezerioBlocks/examples/Bluetooth/Chariot/Chariot.ino index f5a324d..de536ee 100644 --- a/libraries/CezerioBlocks/examples/Chariot/Chariot.ino +++ b/libraries/CezerioBlocks/examples/Bluetooth/Chariot/Chariot.ino @@ -1,7 +1,7 @@ /********************************************** CHARIOT ******************************************/ /* 2xMotionBlock, 1xCubeBlock, 1xMainBlock, 1xDetectBlock, 1xLightBlock, 1xBippBlock */ -#include "SmartBlockFunctions.h" +#include "cezerioBlocks.h" #include "DataTransferFunctions.h" unsigned char timerFlag = 0; @@ -9,105 +9,105 @@ extern unsigned char resolvePacketFlag; extern capturedPacketType capturedPacket; void setup() -{ - initSmartBlocks(); +{ + initcezerioBlocks(); initSmartBlue(); } void loop() { -#if defined(CAN_RECEIVE_INTERRUPT_ENABLE) +#if defined(CAN_RECEIVE_INTERRUPT_ENABLE) if(!digitalRead(CAN_INT)) { - + } #endif if(timerFlag) { - + timerFlag = 0; } - getSmartBlueData(); + getSmartBlueData(); if(resolvePacketFlag) { switch(capturedPacket.data_packet.packet_id) - { + { case BLE_ROBOT_NAME: // gelen robot id "0x00" ve data değeri "0xFF" ise robot id'sini gönderir if(capturedPacket.data_packet.robot_id == 0x00 && capturedPacket.data_packet.data[0] == 0xFF) { sendChariotData(BLE_ROBOT_NAME, 0xFF); } - break; - + break; + case BLE_MOVE_FORWARD: setMotion(0x140, motorDirectionForward, capturedPacket.data_packet.data[0], motorDriverEnable); /*Front_Left Wheel*/ setMotion(0x141, motorDirectionForward, capturedPacket.data_packet.data[0], motorDriverEnable); /*Front_Right Wheel*/ break; - + case BLE_MOVE_BACKWARD: setMotion(0x140, motorDirectionBackward, capturedPacket.data_packet.data[0], motorDriverEnable); /*Front_Left Wheel*/ setMotion(0x141, motorDirectionBackward, capturedPacket.data_packet.data[0], motorDriverEnable); /*Front_Right Wheel*/ break; - + case BLE_MOVE_RIGHT: setMotion(0x140,motorDirectionForward,capturedPacket.data_packet.data[0],motorDriverEnable); /*Front_Left Wheel*/ setMotion(0x141,motorDirectionForward,(capturedPacket.data_packet.data[0])/2,motorDriverEnable); /*Front_Right Wheel*/ break; - + case BLE_MOVE_LEFT: setMotion(0x140,motorDirectionForward,(capturedPacket.data_packet.data[0])/2,motorDriverEnable); /*Front_Left Wheel*/ setMotion(0x141,motorDirectionForward,capturedPacket.data_packet.data[0],motorDriverEnable); /*Front_Right Wheel*/ break; - + case BLE_MOVE_FORWARD_RIGHT: setMotion(0x140,motorDirectionForward,capturedPacket.data_packet.data[0],motorDriverEnable); /*Front_Left Wheel*/ setMotion(0x141,motorDirectionForward,(capturedPacket.data_packet.data[0])*0.75,motorDriverEnable); /*Front_Right Wheel*/ break; - + case BLE_MOVE_FORWARD_LEFT: setMotion(0x140,motorDirectionForward,(capturedPacket.data_packet.data[0])*0.75,motorDriverEnable); /*Front_Left Wheel*/ setMotion(0x141,motorDirectionForward,capturedPacket.data_packet.data[0],motorDriverEnable); /*Front_Right Wheel*/ break; - + case BLE_MOVE_BACKWARD_RIGHT: setMotion(0x140, motorDirectionBackward, capturedPacket.data_packet.data[0], motorDriverEnable); /*Front_Left Wheel*/ setMotion(0x141, motorDirectionBackward, (capturedPacket.data_packet.data[0])*0.75, motorDriverEnable); /*Front_Right Wheel*/ break; - + case BLE_MOVE_BACKWARD_LEFT: setMotion(0x140, motorDirectionBackward, (capturedPacket.data_packet.data[0])*0.75, motorDriverEnable); /*Front_Left Wheel*/ setMotion(0x141, motorDirectionBackward, capturedPacket.data_packet.data[0], motorDriverEnable); /*Front_Right Wheel*/ break; - - case BLE STOP: + + case BLE_STOP: setMotion(0x140, motorDirectionForward, 0, motorDriverEnable); /*Front_Left Wheel*/ setMotion(0x141, motorDirectionForward, 0, motorDriverEnable); /*Front_Right Wheel*/ break; - + case BLE_TURN_360CW: setMotion(0x140, motorDirectionForward, 255, motorDriverEnable); /*Front_Left Wheel*/ setMotion(0x141, motorDirectionBackward, 255, motorDriverEnable); /*Front_Right Wheel*/ break; - + case BLE_TURN_360CCW: setMotion(0x140, motorDirectionBackward, 255, motorDriverEnable); /*Front_Left Wheel*/ setMotion(0x141, motorDirectionForward, 255, motorDriverEnable); /*Front_Right Wheel*/ break; - + case BLE_DETECT_DATA: sendChariotData(BLE_DETECT_DATA, getDetect(0x020)); break; - + case BLE_BIPP: setBipp(0x0E0,capturedPacket.data_packet.data[0]); break; - + case BLE_LIGHT: setLight(0x120,capturedPacket.data_packet.data[0]); break; - + } } } diff --git a/libraries/CezerioBlocks/examples/Flying_Car/Flying_Car.ino b/libraries/CezerioBlocks/examples/Bluetooth/Flying_Car/Flying_Car.ino similarity index 94% rename from libraries/CezerioBlocks/examples/Flying_Car/Flying_Car.ino rename to libraries/CezerioBlocks/examples/Bluetooth/Flying_Car/Flying_Car.ino index c9cda4b..cfdc686 100644 --- a/libraries/CezerioBlocks/examples/Flying_Car/Flying_Car.ino +++ b/libraries/CezerioBlocks/examples/Bluetooth/Flying_Car/Flying_Car.ino @@ -1,7 +1,7 @@ /********************************************** FLYING_CAR ******************************************/ /* 3xMotionBlock, 3xCubeBlock, 1xMainBlock, 1xDetectBlock, 1xLightBlock, 1xBippBlock */ -#include "SmartBlockFunctions.h" +#include "cezerioBlocks.h" #include "DataTransferFunctions.h" unsigned char timerFlag = 0; @@ -9,110 +9,110 @@ extern unsigned char resolvePacketFlag; extern capturedPacketType capturedPacket; void setup() -{ - initSmartBlocks(); +{ + initcezerioBlocks(); initSmartBlue(); } void loop() { -#if defined(CAN_RECEIVE_INTERRUPT_ENABLE) +#if defined(CAN_RECEIVE_INTERRUPT_ENABLE) if(!digitalRead(CAN_INT)) { - + } #endif if(timerFlag) { - + timerFlag = 0; } - getSmartBlueData(); + getSmartBlueData(); if(resolvePacketFlag) { switch(capturedPacket.data_packet.packet_id) - { + { case BLE_ROBOT_NAME: // gelen robot id "0x00" ve data değeri "0xFF" ise robot id'sini gönderir if(capturedPacket.data_packet.robot_id == 0x00 && capturedPacket.data_packet.data[0] == 0xFF) { sendFlyingCarData(BLE_ROBOT_NAME, 0xFF); } - break; - + break; + case BLE_MOVE_FORWARD: setMotion(0x140, motorDirectionForward, capturedPacket.data_packet.data[0], motorDriverEnable); /*Front_Left Wheel*/ setMotion(0x141, motorDirectionForward, capturedPacket.data_packet.data[0], motorDriverEnable); /*Front_Right Wheel*/ break; - + case BLE_MOVE_BACKWARD: setMotion(0x140, motorDirectionBackward, capturedPacket.data_packet.data[0], motorDriverEnable); /*Front_Left Wheel*/ setMotion(0x141, motorDirectionBackward, capturedPacket.data_packet.data[0], motorDriverEnable); /*Front_Right Wheel*/ break; - + case BLE_MOVE_RIGHT: setMotion(0x140,motorDirectionForward,capturedPacket.data_packet.data[0],motorDriverEnable); /*Front_Left Wheel*/ setMotion(0x141,motorDirectionForward,(capturedPacket.data_packet.data[0])/2,motorDriverEnable); /*Front_Right Wheel*/ break; - + case BLE_MOVE_LEFT: setMotion(0x140,motorDirectionForward,(capturedPacket.data_packet.data[0])/2,motorDriverEnable); /*Front_Left Wheel*/ setMotion(0x141,motorDirectionForward,capturedPacket.data_packet.data[0],motorDriverEnable); /*Front_Right Wheel*/ break; - + case BLE_MOVE_FORWARD_RIGHT: setMotion(0x140,motorDirectionForward,capturedPacket.data_packet.data[0],motorDriverEnable); /*Front_Left Wheel*/ setMotion(0x141,motorDirectionForward,(capturedPacket.data_packet.data[0])*0.75,motorDriverEnable); /*Front_Right Wheel*/ break; - + case BLE_MOVE_FORWARD_LEFT: setMotion(0x140,motorDirectionForward,(capturedPacket.data_packet.data[0])*0.75,motorDriverEnable); /*Front_Left Wheel*/ setMotion(0x141,motorDirectionForward,capturedPacket.data_packet.data[0],motorDriverEnable); /*Front_Right Wheel*/ break; - + case BLE_MOVE_BACKWARD_RIGHT: setMotion(0x140, motorDirectionBackward, capturedPacket.data_packet.data[0], motorDriverEnable); /*Front_Left Wheel*/ setMotion(0x141, motorDirectionBackward, (capturedPacket.data_packet.data[0])*0.75, motorDriverEnable); /*Front_Right Wheel*/ break; - + case BLE_MOVE_BACKWARD_LEFT: setMotion(0x140, motorDirectionBackward, (capturedPacket.data_packet.data[0])*0.75, motorDriverEnable); /*Front_Left Wheel*/ setMotion(0x141, motorDirectionBackward, capturedPacket.data_packet.data[0], motorDriverEnable); /*Front_Right Wheel*/ break; - - case BLE STOP: + + case BLE_STOP: setMotion(0x140, motorDirectionForward, 0, motorDriverEnable); /*Front_Left Wheel*/ setMotion(0x141, motorDirectionForward, 0, motorDriverEnable); /*Front_Right Wheel*/ break; - + case BLE_TURN_360CW: setMotion(0x140, motorDirectionForward, 255, motorDriverEnable); /*Front_Left Wheel*/ setMotion(0x141, motorDirectionBackward, 255, motorDriverEnable); /*Front_Right Wheel*/ break; - + case BLE_TURN_360CCW: setMotion(0x140, motorDirectionBackward, 255, motorDriverEnable); /*Front_Left Wheel*/ setMotion(0x141, motorDirectionForward, 255, motorDriverEnable); /*Front_Right Wheel*/ break; - + case BLE_FLIP: setMotion(0x142, motorDirectionForward, capturedPacket.data_packet.data[0], motorDriverEnable); /*Propeller*/ break; - + case BLE_DETECT_DATA: sendFlyingCarData(BLE_DETECT_DATA, getDetect(0x020)); break; - + case BLE_BIPP: setBipp(0x0E0,capturedPacket.data_packet.data[0]); break; - + case BLE_LIGHT: setLight(0x120,capturedPacket.data_packet.data[0]); break; - + } } } diff --git a/libraries/CezerioBlocks/examples/Roller/Roller.ino b/libraries/CezerioBlocks/examples/Bluetooth/Roller/Roller.ino similarity index 93% rename from libraries/CezerioBlocks/examples/Roller/Roller.ino rename to libraries/CezerioBlocks/examples/Bluetooth/Roller/Roller.ino index 42b33c2..dba6b39 100644 --- a/libraries/CezerioBlocks/examples/Roller/Roller.ino +++ b/libraries/CezerioBlocks/examples/Bluetooth/Roller/Roller.ino @@ -1,7 +1,7 @@ /********************************************** ROLLER ******************************************/ /* 2xMotionBlock, 2xCubeBlock, 1xMainBlock */ -#include "SmartBlockFunctions.h" +#include "cezerioBlocks.h" #include "DataTransferFunctions.h" unsigned char timerFlag = 0; @@ -9,93 +9,93 @@ extern unsigned char resolvePacketFlag; extern capturedPacketType capturedPacket; void setup() -{ - initSmartBlocks(); +{ + initcezerioBlocks(); initSmartBlue(); } void loop() { -#if defined(CAN_RECEIVE_INTERRUPT_ENABLE) +#if defined(CAN_RECEIVE_INTERRUPT_ENABLE) if(!digitalRead(CAN_INT)) { - + } #endif if(timerFlag) { - + timerFlag = 0; } - getSmartBlueData(); + getSmartBlueData(); if(resolvePacketFlag) { switch(capturedPacket.data_packet.packet_id) - { + { case BLE_ROBOT_NAME: // gelen robot id "0x00" ve data değeri "0xFF" ise robot id'sini gönderir if(capturedPacket.data_packet.robot_id == 0x00 && capturedPacket.data_packet.data[0] == 0xFF) { sendRollerData(BLE_ROBOT_NAME, 0xFF); } - break; - + break; + case BLE_MOVE_FORWARD: setMotion(0x140, motorDirectionForward, capturedPacket.data_packet.data[0], motorDriverEnable); /*Front_Left Wheel*/ setMotion(0x141, motorDirectionForward, capturedPacket.data_packet.data[0], motorDriverEnable); /*Front_Right Wheel*/ break; - + case BLE_MOVE_BACKWARD: setMotion(0x140, motorDirectionBackward, capturedPacket.data_packet.data[0], motorDriverEnable); /*Front_Left Wheel*/ setMotion(0x141, motorDirectionBackward, capturedPacket.data_packet.data[0], motorDriverEnable); /*Front_Right Wheel*/ break; - + case BLE_MOVE_RIGHT: setMotion(0x140,motorDirectionForward,capturedPacket.data_packet.data[0],motorDriverEnable); /*Front_Left Wheel*/ setMotion(0x141,motorDirectionForward,(capturedPacket.data_packet.data[0])/2,motorDriverEnable); /*Front_Right Wheel*/ break; - + case BLE_MOVE_LEFT: setMotion(0x140,motorDirectionForward,(capturedPacket.data_packet.data[0])/2,motorDriverEnable); /*Front_Left Wheel*/ setMotion(0x141,motorDirectionForward,capturedPacket.data_packet.data[0],motorDriverEnable); /*Front_Right Wheel*/ break; - + case BLE_MOVE_FORWARD_RIGHT: setMotion(0x140,motorDirectionForward,capturedPacket.data_packet.data[0],motorDriverEnable); /*Front_Left Wheel*/ setMotion(0x141,motorDirectionForward,(capturedPacket.data_packet.data[0])*0.75,motorDriverEnable); /*Front_Right Wheel*/ break; - + case BLE_MOVE_FORWARD_LEFT: setMotion(0x140,motorDirectionForward,(capturedPacket.data_packet.data[0])*0.75,motorDriverEnable); /*Front_Left Wheel*/ setMotion(0x141,motorDirectionForward,capturedPacket.data_packet.data[0],motorDriverEnable); /*Front_Right Wheel*/ break; - + case BLE_MOVE_BACKWARD_RIGHT: setMotion(0x140, motorDirectionBackward, capturedPacket.data_packet.data[0], motorDriverEnable); /*Front_Left Wheel*/ setMotion(0x141, motorDirectionBackward, (capturedPacket.data_packet.data[0])*0.75, motorDriverEnable); /*Front_Right Wheel*/ break; - + case BLE_MOVE_BACKWARD_LEFT: setMotion(0x140, motorDirectionBackward, (capturedPacket.data_packet.data[0])*0.75, motorDriverEnable); /*Front_Left Wheel*/ setMotion(0x141, motorDirectionBackward, capturedPacket.data_packet.data[0], motorDriverEnable); /*Front_Right Wheel*/ break; - - case BLE STOP: + + case BLE_STOP: setMotion(0x140, motorDirectionForward, 0, motorDriverEnable); /*Front_Left Wheel*/ setMotion(0x141, motorDirectionForward, 0, motorDriverEnable); /*Front_Right Wheel*/ break; - + case BLE_TURN_360CW: setMotion(0x140, motorDirectionForward, 255, motorDriverEnable); /*Front_Left Wheel*/ setMotion(0x141, motorDirectionBackward, 255, motorDriverEnable); /*Front_Right Wheel*/ break; - + case BLE_TURN_360CCW: setMotion(0x140, motorDirectionBackward, 255, motorDriverEnable); /*Front_Left Wheel*/ setMotion(0x141, motorDirectionForward, 255, motorDriverEnable); /*Front_Right Wheel*/ break; - + } } } diff --git a/libraries/CezerioBlocks/examples/SendReceiveBluetooth/SendReceiveBluetooth.ino b/libraries/CezerioBlocks/examples/Bluetooth/SendReceiveBluetooth/SendReceiveBluetooth.ino similarity index 77% rename from libraries/CezerioBlocks/examples/SendReceiveBluetooth/SendReceiveBluetooth.ino rename to libraries/CezerioBlocks/examples/Bluetooth/SendReceiveBluetooth/SendReceiveBluetooth.ino index b3fba89..3590c6f 100644 --- a/libraries/CezerioBlocks/examples/SendReceiveBluetooth/SendReceiveBluetooth.ino +++ b/libraries/CezerioBlocks/examples/Bluetooth/SendReceiveBluetooth/SendReceiveBluetooth.ino @@ -1,22 +1,4 @@ -/* - SendReceiveBluetooth.ino - 2017 Copyright (c) RFtek Electronics Ltd. All right reserved. - - Authors : Huseyin Ulvi AYDOGMUS, Ozgur BOSTAN - Date : 2017-04-28 - - This sketch is a demo template for the logical operations of - SmartBlock Bluetooth functions. - - the SmartBlocks: 2x Knob Block, 1x Detect Block (Input Blocks) - 2x Lıght Block, 1x Bipp Block, 1x Motion Block (Output Blocks) - - Note: Any of the interrupt capabilities can be used by uncommenting the - #define statements (TIMER and/or CAN RECEIVE interrupt) - -*/ - -#include "SmartBlockFunctions.h" +#include "cezerioBlocks.h" #include "DataTransferFunctions.h" unsigned char timerFlag = 0; @@ -24,43 +6,43 @@ extern unsigned char resolvePacketFlag; extern capturedPacketType capturedPacket; void setup() -{ - initSmartBlocks(); +{ + initcezerioBlocks(); initSmartBlue(); } void loop() { -#if defined(CAN_RECEIVE_INTERRUPT_ENABLE) +#if defined(CAN_RECEIVE_INTERRUPT_ENABLE) if(!digitalRead(CAN_INT)) { - + } #endif if(timerFlag) { - + timerFlag = 0; } - getSmartBlueData(); + getSmartBlueData(); if(resolvePacketFlag) { switch(capturedPacket.data_packet.packet_id) - { + { case BLE_ROBOT_NAME: // gelen robot id "0x00" ve data değeri "0xFF" ise robot id'sini gönderir if(capturedPacket.data_packet.robot_id == 0x00 && capturedPacket.data_packet.data[0] == 0xFF) { sendRollerData(BLE_ROBOT_NAME, 0xFF); } - - break; + + break; case BLE_MOVE_FORWARD: - + break; case BLE_MOVE_BACKWARD: @@ -84,7 +66,7 @@ void loop() break; case BLE_MOVE_FORWARD_LEFT: - + break; case BLE_MOVE_BACKWARD_RIGHT: @@ -120,7 +102,7 @@ void loop() break; case BLE_FLIP: - + break; case BLE_STOP: @@ -262,9 +244,9 @@ void loop() break; default: - + break; - } + } resolvePacketFlag = 0; } @@ -276,6 +258,3 @@ ISR(TIMER1_COMPA_vect) timerFlag = 1; } #endif -/********************************************************************************************************* - END FILE -*********************************************************************************************************/ diff --git a/libraries/CezerioBlocks/examples/Truck/Truck.ino b/libraries/CezerioBlocks/examples/Bluetooth/Truck/Truck.ino similarity index 96% rename from libraries/CezerioBlocks/examples/Truck/Truck.ino rename to libraries/CezerioBlocks/examples/Bluetooth/Truck/Truck.ino index 2275207..315ceae 100644 --- a/libraries/CezerioBlocks/examples/Truck/Truck.ino +++ b/libraries/CezerioBlocks/examples/Bluetooth/Truck/Truck.ino @@ -1,7 +1,7 @@ /********************************************** TRUCK ******************************************/ /* 4xMotionBlock, 2xCubeBlock, 1xMainBlock, 1xDetectBlock, 1xLightBlock, 1xBippBlock */ -#include "SmartBlockFunctions.h" +#include "cezerioBlocks.h" #include "DataTransferFunctions.h" unsigned char timerFlag = 0; @@ -9,127 +9,127 @@ extern unsigned char resolvePacketFlag; extern capturedPacketType capturedPacket; void setup() -{ - initSmartBlocks(); +{ + initcezerioBlocks(); initSmartBlue(); } void loop() { -#if defined(CAN_RECEIVE_INTERRUPT_ENABLE) +#if defined(CAN_RECEIVE_INTERRUPT_ENABLE) if(!digitalRead(CAN_INT)) { - + } #endif if(timerFlag) { - + timerFlag = 0; } - getSmartBlueData(); + getSmartBlueData(); if(resolvePacketFlag) { switch(capturedPacket.data_packet.packet_id) - { + { case BLE_ROBOT_NAME: // gelen robot id "0x00" ve data değeri "0xFF" ise robot id'sini gönderir if(capturedPacket.data_packet.robot_id == 0x00 && capturedPacket.data_packet.data[0] == 0xFF) { sendTruckData(BLE_ROBOT_NAME, 0xFF); } - break; - + break; + case BLE_MOVE_FORWARD: setMotion(0x140, motorDirectionForward, capturedPacket.data_packet.data[0], motorDriverEnable); /*Front_Left Wheel*/ setMotion(0x141, motorDirectionForward, capturedPacket.data_packet.data[0], motorDriverEnable); /*Front_Right Wheel*/ setMotion(0x142, motorDirectionForward, capturedPacket.data_packet.data[0], motorDriverEnable); /*Back_Left Wheel*/ setMotion(0x143, motorDirectionForward, capturedPacket.data_packet.data[0], motorDriverEnable); /*Back_Right Wheel*/ break; - + case BLE_MOVE_BACKWARD: setMotion(0x140, motorDirectionBackward, capturedPacket.data_packet.data[0], motorDriverEnable); /*Front_Left Wheel*/ setMotion(0x141, motorDirectionBackward, capturedPacket.data_packet.data[0], motorDriverEnable); /*Front_Right Wheel*/ setMotion(0x142, motorDirectionBackward, capturedPacket.data_packet.data[0], motorDriverEnable); /*Back_Left Wheel*/ setMotion(0x143, motorDirectionBackward, capturedPacket.data_packet.data[0], motorDriverEnable); /*Back_Right Wheel*/ break; - + case BLE_MOVE_RIGHT: setMotion(0x140,motorDirectionForward,capturedPacket.data_packet.data[0],motorDriverEnable); /*Front_Left Wheel*/ setMotion(0x141,motorDirectionForward,(capturedPacket.data_packet.data[0])/2,motorDriverEnable); /*Front_Right Wheel*/ setMotion(0x142,motorDirectionForward,capturedPacket.data_packet.data[0],motorDriverEnable); /*Back_Left Wheel*/ setMotion(0x143,motorDirectionForward,(capturedPacket.data_packet.data[0])/2,motorDriverEnable); /*Back_Right Wheel*/ break; - + case BLE_MOVE_LEFT: setMotion(0x140,motorDirectionForward,(capturedPacket.data_packet.data[0])/2,motorDriverEnable); /*Front_Left Wheel*/ setMotion(0x141,motorDirectionForward,capturedPacket.data_packet.data[0],motorDriverEnable); /*Front_Right Wheel*/ setMotion(0x142,motorDirectionForward,(capturedPacket.data_packet.data[0])/2,motorDriverEnable); /*Back_Left Wheel*/ setMotion(0x143,motorDirectionForward,capturedPacket.data_packet.data[0],motorDriverEnable); /*Back_Right Wheel*/ break; - + case BLE_MOVE_FORWARD_RIGHT: setMotion(0x140,motorDirectionForward,capturedPacket.data_packet.data[0],motorDriverEnable); /*Front_Left Wheel*/ setMotion(0x141,motorDirectionForward,(capturedPacket.data_packet.data[0])*0.75,motorDriverEnable); /*Front_Right Wheel*/ setMotion(0x142,motorDirectionForward,capturedPacket.data_packet.data[0],motorDriverEnable); /*Back_Left Wheel*/ setMotion(0x143,motorDirectionForward,(capturedPacket.data_packet.data[0])*0.75,motorDriverEnable); /*Back_Right Wheel*/ break; - + case BLE_MOVE_FORWARD_LEFT: setMotion(0x140,motorDirectionForward,(capturedPacket.data_packet.data[0])*0.75,motorDriverEnable); /*Front_Left Wheel*/ setMotion(0x141,motorDirectionForward,capturedPacket.data_packet.data[0],motorDriverEnable); /*Front_Right Wheel*/ setMotion(0x142,motorDirectionForward,(capturedPacket.data_packet.data[0])*0.75,motorDriverEnable); /*Back_Left Wheel*/ setMotion(0x143,motorDirectionForward,capturedPacket.data_packet.data[0],motorDriverEnable); /*Back_Right Wheel*/ break; - + case BLE_MOVE_BACKWARD_RIGHT: setMotion(0x140, motorDirectionBackward, capturedPacket.data_packet.data[0], motorDriverEnable); /*Front_Left Wheel*/ setMotion(0x141, motorDirectionBackward, (capturedPacket.data_packet.data[0])*0.75, motorDriverEnable); /*Front_Right Wheel*/ setMotion(0x142, motorDirectionBackward, capturedPacket.data_packet.data[0], motorDriverEnable); /*Back_Left Wheel*/ setMotion(0x143, motorDirectionBackward, (capturedPacket.data_packet.data[0])*0.75, motorDriverEnable); /*Back_Right Wheel*/ break; - + case BLE_MOVE_BACKWARD_LEFT: setMotion(0x140, motorDirectionBackward, (capturedPacket.data_packet.data[0])*0.75, motorDriverEnable); /*Front_Left Wheel*/ setMotion(0x141, motorDirectionBackward, capturedPacket.data_packet.data[0], motorDriverEnable); /*Front_Right Wheel*/ setMotion(0x142, motorDirectionBackward, (capturedPacket.data_packet.data[0])*0.75, motorDriverEnable); /*Back_Left Wheel*/ setMotion(0x143, motorDirectionBackward, capturedPacket.data_packet.data[0], motorDriverEnable); /*Back_Right Wheel*/ break; - - case BLE STOP: + + case BLE_STOP: setMotion(0x140, motorDirectionForward, 0, motorDriverEnable); /*Front_Left Wheel*/ setMotion(0x141, motorDirectionForward, 0, motorDriverEnable); /*Front_Right Wheel*/ setMotion(0x142, motorDirectionForward, 0, motorDriverEnable); /*Back_Left Wheel*/ setMotion(0x143, motorDirectionForward, 0, motorDriverEnable); /*Back_Right Wheel*/ break; - + case BLE_TURN_360CW: setMotion(0x140, motorDirectionForward, 255, motorDriverEnable); /*Front_Left Wheel*/ setMotion(0x141, motorDirectionBackward, 255, motorDriverEnable); /*Front_Right Wheel*/ setMotion(0x142, motorDirectionForward, 255, motorDriverEnable); /*Back_Left Wheel*/ setMotion(0x143, motorDirectionBackward, 255, motorDriverEnable); /*Back_Right Wheel*/ break; - + case BLE_TURN_360CCW: setMotion(0x140, motorDirectionBackward, 255, motorDriverEnable); /*Front_Left Wheel*/ setMotion(0x141, motorDirectionForward, 255, motorDriverEnable); /*Front_Right Wheel*/ setMotion(0x142, motorDirectionBackward, 255, motorDriverEnable); /*Back_Left Wheel*/ setMotion(0x143, motorDirectionForward, 255, motorDriverEnable); /*Back_Right Wheel*/ break; - + case BLE_DETECT_DATA: sendTruckData(BLE_DETECT_DATA, getDetect(0x020)); break; - + case BLE_BIPP: setBipp(0x0E0,capturedPacket.data_packet.data[0]); break; - + case BLE_LIGHT: setLight(0x120,capturedPacket.data_packet.data[0]); break; - + } } } diff --git a/libraries/CezerioBlocks/examples/Windmill/Windmill.ino b/libraries/CezerioBlocks/examples/Bluetooth/Windmill/Windmill.ino similarity index 87% rename from libraries/CezerioBlocks/examples/Windmill/Windmill.ino rename to libraries/CezerioBlocks/examples/Bluetooth/Windmill/Windmill.ino index 9648d5c..51fd0cf 100644 --- a/libraries/CezerioBlocks/examples/Windmill/Windmill.ino +++ b/libraries/CezerioBlocks/examples/Bluetooth/Windmill/Windmill.ino @@ -1,7 +1,7 @@ /********************************************** WINDMILL ******************************************/ /* 1xMotionBlock, 3xCubeBlock, 1xMainBlock, 1xDetectBlock, 1xLightBlock, 1xBippBlock, 1xLevelBlock, 1xMicBlock, 1xPhotoBlock, 1xKnobBlock */ -#include "SmartBlockFunctions.h" +#include "cezerioBlocks.h" #include "DataTransferFunctions.h" unsigned char timerFlag = 0; @@ -9,69 +9,70 @@ extern unsigned char resolvePacketFlag; extern capturedPacketType capturedPacket; void setup() -{ - initSmartBlocks(); +{ + initcezerioBlocks(); initSmartBlue(); } void loop() { -#if defined(CAN_RECEIVE_INTERRUPT_ENABLE) +#if defined(CAN_RECEIVE_INTERRUPT_ENABLE) if(!digitalRead(CAN_INT)) { - + } #endif if(timerFlag) { - + timerFlag = 0; } - getSmartBlueData(); + getSmartBlueData(); if(resolvePacketFlag) { switch(capturedPacket.data_packet.packet_id) - { + { case BLE_ROBOT_NAME: // gelen robot id "0x00" ve data değeri "0xFF" ise robot id'sini gönderir if(capturedPacket.data_packet.robot_id == 0x00 && capturedPacket.data_packet.data[0] == 0xFF) { sendWindmillData(BLE_ROBOT_NAME, 0xFF); } - break; - + break; + case BLE_FLIP: setMotion(0x142, motorDirectionForward, capturedPacket.data_packet.data[0], motorDriverEnable); /*Propeller*/ break; - + case BLE_BIPP: setBipp(0x0E0,capturedPacket.data_packet.data[0]); break; - + case BLE_LIGHT: setLight(0x120,capturedPacket.data_packet.data[0]); break; - + case BLE_LEVEL: setLevel(0x110,capturedPacket.data_packet.data[0]); break; - + case BLE_DETECT_DATA: sendWindmillData(BLE_DETECT_DATA, getDetect(0x020)); break; - + case BLE_PHOTO_DATA: sendWindmillData(BLE_PHOTO_DATA, getPhoto(0x070)); - break; - + break; + case BLE_MIC_DATA: sendWindmillData(BLE_MIC_DATA, getMic(0x060)); - break; - + break; + case BLE_KNOB_DATA: sendWindmillData(BLE_KNOB_DATA, getKnob(0x050)); break; + } } } diff --git a/libraries/CezerioBlocks/examples/Level/Level.ino b/libraries/CezerioBlocks/examples/Level/Level.ino new file mode 100644 index 0000000..e016882 --- /dev/null +++ b/libraries/CezerioBlocks/examples/Level/Level.ino @@ -0,0 +1,37 @@ +#include "cezerioBlocks.h" + +#define knob 0x050 +#define level 0x110 + +unsigned char timerFlag = 0; + +void setup() +{ + initcezerioBlocks(); +} + +void loop() +{ +#if defined(CAN_RECEIVE_INTERRUPT_ENABLE) + if(!digitalRead(CAN_INT)) + { + + } +#endif + + if(timerFlag) + { + + unsigned char knobValue = getKnob(knob); + setLevel(level,knobValue); + + timerFlag = 0; + } +} + +#if defined(TIMER_INTERRUPT_ENABLE) +ISR(TIMER1_COMPA_vect) +{ + timerFlag = 1; +} +#endif diff --git a/libraries/CezerioBlocks/examples/MotionDetector/MotionDetector.ino b/libraries/CezerioBlocks/examples/MotionDetector/MotionDetector.ino new file mode 100644 index 0000000..a5d6bb7 --- /dev/null +++ b/libraries/CezerioBlocks/examples/MotionDetector/MotionDetector.ino @@ -0,0 +1,46 @@ +#include "cezerioBlocks.h" + +#define bipp 0x0E0 +#define gesture 0x040 + +unsigned char timerFlag = 0; + +void setup() +{ + initcezerioBlocks(); +} + +void loop() +{ +#if defined(CAN_RECEIVE_INTERRUPT_ENABLE) + if(!digitalRead(CAN_INT)) + { + + } +#endif + +if(timerFlag) +{ +unsigned char hareket = getGesture(gesture); + + if (hareket == 1) + { + setBipp(bipp, 1); + hareket = getGesture(gesture); + } + else + { + setBipp(bipp, 0); + hareket = getGesture(gesture); + } + + timerFlag = 0; + } +} + +#if defined(TIMER_INTERRUPT_ENABLE) +ISR(TIMER1_COMPA_vect) +{ + timerFlag = 1; +} +#endif diff --git a/libraries/CezerioBlocks/examples/NightLamb/NightLamb.ino b/libraries/CezerioBlocks/examples/NightLamb/NightLamb.ino new file mode 100644 index 0000000..02eaa18 --- /dev/null +++ b/libraries/CezerioBlocks/examples/NightLamb/NightLamb.ino @@ -0,0 +1,45 @@ +#include "cezerioBlocks.h" + +#define photo 0x070 +#define light 0x120 + +unsigned char timerFlag = 0; + +void setup() +{ + initcezerioBlocks(); +} + +void loop() +{ +#if defined(CAN_RECEIVE_INTERRUPT_ENABLE) + if(!digitalRead(CAN_INT)) + { + + } +#endif + + if(timerFlag) + { + + unsigned char photoLevel = getPhoto(photo); + + if(photoLevel>=200) + { + setLight(light, HIGH); + } + else + { + setLight(light, LOW); + } + + timerFlag = 0; + } +} + +#if defined(TIMER_INTERRUPT_ENABLE) +ISR(TIMER1_COMPA_vect) +{ + timerFlag = 1; +} +#endif diff --git a/libraries/CezerioBlocks/examples/Runner/Runner.ino b/libraries/CezerioBlocks/examples/Runner/Runner.ino index d79a400..0f812ba 100644 --- a/libraries/CezerioBlocks/examples/Runner/Runner.ino +++ b/libraries/CezerioBlocks/examples/Runner/Runner.ino @@ -1,50 +1,23 @@ -/* - SmartBlockSTM32ArduinoDemo.ino - 2017 Copyright (c) RFtek Electronics Ltd. All right reserved. - - Authors : Huseyin Ulvi AYDOGMUS, Ozgur BOSTAN - Date : 2017-03-21 - - This sketch is a demo template for the logical operations of - SmartBlock functions. SmartBlockFunctions.cpp v1.1.0 is used. - - the SmartBlocks: 2x Detect Block (Input Blocks) - 2x Motion Block (Output Blocks) - - Note: Any of the interrupt capabilities can be used by uncommenting the - #define statements (TIMER and/or CAN RECEIVE interrupt) - -*/ - -#include "SmartBlockFunctions.h" +#include "cezerioBlocks.h" #define blackDetect 0x020 #define redDetect 0x021 -#define knob 0x050 -#define mic 0x060 -#define photo 0x070 -#define bipp 0x0E0 -#define level 0x110 -#define light 0x120 #define purpleMotor 0x140 #define orangeMotor 0x141 -#define redMotor 0x142 -#define blueMotor 0x143 -#define propellerMotor 0x144 unsigned char timerFlag = 0; void setup() -{ - initSmartBlocks(); +{ + initcezerioBlocks(); } void loop() { -#if defined(CAN_RECEIVE_INTERRUPT_ENABLE) +#if defined(CAN_RECEIVE_INTERRUPT_ENABLE) if(!digitalRead(CAN_INT)) { - + } #endif @@ -64,11 +37,16 @@ void loop() setMotion(purpleMotor, motorDirectionForward, 255, motorDriverEnable); setMotion(orangeMotor, motorDirectionForward, 255, motorDriverEnable); } - else() + else if(forwardObject>=1 && backwardObject>=1) { setMotion(purpleMotor, motorDirectionForward, 0, motorDriverEnable); setMotion(orangeMotor, motorDirectionForward, 0, motorDriverEnable); } + else + { + setMotion(purpleMotor, motorDirectionForward, 255, motorDriverEnable); + setMotion(orangeMotor, motorDirectionBackward, 255, motorDriverEnable); + } timerFlag = 0; } } @@ -79,6 +57,3 @@ ISR(TIMER1_COMPA_vect) timerFlag = 1; } #endif -/********************************************************************************************************* - END FILE -*********************************************************************************************************/ diff --git a/libraries/CezerioBlocks/examples/SendReceive/SendReceive.ino b/libraries/CezerioBlocks/examples/SendReceive/SendReceive.ino index b0098e1..5742521 100644 --- a/libraries/CezerioBlocks/examples/SendReceive/SendReceive.ino +++ b/libraries/CezerioBlocks/examples/SendReceive/SendReceive.ino @@ -1,36 +1,18 @@ -/* - SendReceive.ino - 2017 Copyright (c) RFtek Electronics Ltd. All right reserved. - - Authors : Huseyin Ulvi AYDOGMUS, Ozgur BOSTAN - Date : 2017-03-21 - - This sketch is a demo template for the logical operations of - SmartBlock functions. SmartBlockFunctions.cpp v1.3.0 is used. - - the SmartBlocks: 2x Knob Block, 1x Detect Block (Input Blocks) - 1x Lıght Block, 1x Bipp Block, 1x Motion Block (Output Blocks) - - Note: Any of the interrupt capabilities can be used by uncommenting the - #define statements (TIMER and/or CAN RECEIVE interrupt) - -*/ - -#include "SmartBlockFunctions.h" +#include "cezerioBlocks.h" unsigned char timerFlag = 0; void setup() -{ - initSmartBlocks(); +{ + initcezerioBlocks(); } void loop() { -#if defined(CAN_RECEIVE_INTERRUPT_ENABLE) +#if defined(CAN_RECEIVE_INTERRUPT_ENABLE) if(!digitalRead(CAN_INT)) { - + } #endif @@ -38,10 +20,10 @@ void loop() { unsigned char motorSpeed = getKnob(MESSAGE_ID_KNOB_BLOCK); setMotion(MESSAGE_ID_MOTION_BLOCK, motorDirectionForward, motorSpeed, motorDriverEnable); - + unsigned char ledState = (getKnob(MESSAGE_ID_KNOB_BLOCK + 1) < 0x7F) ? 0 : 1; setLight(MESSAGE_ID_LIGHT_BLOCK, ledState); - + unsigned char buzzerState = !getDetect(MESSAGE_ID_DETECT_BLOCK); setBipp(MESSAGE_ID_BIPP_BLOCK, buzzerState); @@ -55,6 +37,3 @@ ISR(TIMER1_COMPA_vect) timerFlag = 1; } #endif -/********************************************************************************************************* - END FILE -*********************************************************************************************************/ diff --git a/libraries/CezerioBlocks/examples/Sensormatic/Sensormatic.ino b/libraries/CezerioBlocks/examples/Sensormatic/Sensormatic.ino index 665390b..0171afd 100644 --- a/libraries/CezerioBlocks/examples/Sensormatic/Sensormatic.ino +++ b/libraries/CezerioBlocks/examples/Sensormatic/Sensormatic.ino @@ -1,49 +1,26 @@ -/* - SmartBlockSTM32ArduinoDemo.ino - 2017 Copyright (c) RFtek Electronics Ltd. All right reserved. - - Authors : Huseyin Ulvi AYDOGMUS, Ozgur BOSTAN - Date : 2017-03-21 - - This sketch is a demo template for the logical operations of - SmartBlock functions. SmartBlockFunctions.cpp v1.1.0 is used. - - the SmartBlocks: 1x KnobBlock, 1x PhotoBlock, 1x MicBlock (Input Blocks) - 1x LıghtBlock, 1xBippBlock, 1xLevelBlock, 1x MotionBlock (Output Blocks) +#include "cezerioBlocks.h" - Note: Any of the interrupt capabilities can be used by uncommenting the - #define statements (TIMER and/or CAN RECEIVE interrupt) -*/ - -#include "SmartBlockFunctions.h" - -#define blackDetect 0x020 -#define redDetect 0x021 #define knob 0x050 #define mic 0x060 #define photo 0x070 #define bipp 0x0E0 -#define level 0x110 +#define level 0x110 #define light 0x120 -#define purpleMotor 0x140 -#define orangeMotor 0x141 -#define redMotor 0x142 -#define blueMotor 0x143 #define propellerMotor 0x144 unsigned char timerFlag = 0; void setup() -{ - initSmartBlocks(); +{ + initcezerioBlocks(); } void loop() { -#if defined(CAN_RECEIVE_INTERRUPT_ENABLE) +#if defined(CAN_RECEIVE_INTERRUPT_ENABLE) if(!digitalRead(CAN_INT)) { - + } #endif @@ -52,26 +29,26 @@ void loop() unsigned char motorSpeed = getKnob(knob); unsigned char photoLevel = getPhoto(photo); unsigned char soundLevel = getMic(mic); - - if(photoLevel<15) + + if(photoLevel>200) { setMotion(propellerMotor, motorDirectionForward, motorSpeed, motorDriverDisable); - setLight(light, 1); - setLevel(level,motorSpeed); + setLight(light, 1); + setLevel(level,motorSpeed); } - if(photoLevel>=15) + if(photoLevel<=200) { setMotion(propellerMotor, motorDirectionForward, motorSpeed, motorDriverEnable); - setLight(light, 0); + setLight(light, 0); setLevel(level,soundLevel); } - if(soundLevel>10) + if(soundLevel>200 || soundLevel<100) { setBipp(bipp,1); setLevel(level,soundLevel); } - if(soundLevel<=10) + else { setBipp(bipp,0); } @@ -85,7 +62,3 @@ ISR(TIMER1_COMPA_vect) timerFlag = 1; } #endif - -/********************************************************************************************************* - END FILE -*********************************************************************************************************/ diff --git a/libraries/CezerioBlocks/examples/ShakyMic/ShakyMic.ino b/libraries/CezerioBlocks/examples/ShakyMic/ShakyMic.ino new file mode 100644 index 0000000..c8ee66e --- /dev/null +++ b/libraries/CezerioBlocks/examples/ShakyMic/ShakyMic.ino @@ -0,0 +1,48 @@ +#include "cezerioBlocks.h" + +#define mic 0x060 +#define birr 0x160 + +unsigned char timerFlag = 0; + +void setup() +{ + initcezerioBlocks(); +} + +void loop() +{ +#if defined(CAN_RECEIVE_INTERRUPT_ENABLE) + if(!digitalRead(CAN_INT)) + { + + } +#endif + + if(timerFlag) + { + + unsigned char micValue = getMic(mic); + Serial.println(micValue); + + if(micValue >= 200|| micValue <= 100) + { + setBirrr(birr, motorDirectionForward, 255, motorDriverEnable); + delay(1500); + } + else + { + setBirrr(birr, motorDirectionForward, 0, motorDriverEnable); + delay(1000); + } + + timerFlag = 0; + } +} + +#if defined(TIMER_INTERRUPT_ENABLE) +ISR(TIMER1_COMPA_vect) +{ + timerFlag = 1; +} +#endif From 67518f81408068a347f21af61065cf1234a344ff Mon Sep 17 00:00:00 2001 From: Dogus Cendek Date: Wed, 14 Jun 2023 19:22:23 +0300 Subject: [PATCH 11/18] Change "initSmartBlocks" to "initcezerioBlocks" Change "initSmartBlocks" to "initcezerioBlocks" Change SmartBlock etc. to "cezerio Blocks" --- libraries/CezerioBlocks/keywords.txt | 2 +- libraries/CezerioBlocks/library.properties | 10 +- ...rtBlockFunctions.cpp => cezerioBlocks.cpp} | 218 +++++++++--------- ...{SmartBlockFunctions.h => cezerioBlocks.h} | 18 +- 4 files changed, 124 insertions(+), 124 deletions(-) rename libraries/CezerioBlocks/src/{SmartBlockFunctions.cpp => cezerioBlocks.cpp} (91%) rename libraries/CezerioBlocks/src/{SmartBlockFunctions.h => cezerioBlocks.h} (96%) diff --git a/libraries/CezerioBlocks/keywords.txt b/libraries/CezerioBlocks/keywords.txt index 3fda369..b6e3010 100644 --- a/libraries/CezerioBlocks/keywords.txt +++ b/libraries/CezerioBlocks/keywords.txt @@ -1,6 +1,6 @@ createDataRequestPacket KEYWORD2 getInputDataAndDriveOutput KEYWORD2 -initSmartBlocks KEYWORD2 +initcezerioBlocks KEYWORD2 initSmartBlue KEYWORD2 getAcc KEYWORD2 diff --git a/libraries/CezerioBlocks/library.properties b/libraries/CezerioBlocks/library.properties index 39eb92d..dd0b0eb 100644 --- a/libraries/CezerioBlocks/library.properties +++ b/libraries/CezerioBlocks/library.properties @@ -1,9 +1,9 @@ -name=the SmartBlock Brain +name=cezerio Blocks version=1.0.1 -author=the SmartBlock Inc. -maintainer=the SmartBlock Inc. -sentence=Main operataional block of the SmartBlock +author=cezerio Blocks +maintainer=cezerio Blocks +sentence=Main operataional block of cezerio Blocks paragraph=Main block gets data from sensor blocks and directs them to actuator blocks with meaningful operational functions. category=Uncategorized -url=https://www.thesmartblock.net +url=https://github.com/cezer-io/cezerio-blocks-arduino architectures=avr diff --git a/libraries/CezerioBlocks/src/SmartBlockFunctions.cpp b/libraries/CezerioBlocks/src/cezerioBlocks.cpp similarity index 91% rename from libraries/CezerioBlocks/src/SmartBlockFunctions.cpp rename to libraries/CezerioBlocks/src/cezerioBlocks.cpp index e7f89ae..2ae2740 100644 --- a/libraries/CezerioBlocks/src/SmartBlockFunctions.cpp +++ b/libraries/CezerioBlocks/src/cezerioBlocks.cpp @@ -1,7 +1,7 @@ /* - SmartBlockFunctions.cpp + cezerioBlocks.cpp 2017 Copyright (c) RFtek Electronics Ltd. All right reserved. - + Authors : Huseyin Ulvi AYDOGMUS, Ozgur BOSTAN Date : 2017-03-20 Version : 1.0.0 @@ -18,16 +18,16 @@ Date : 2017-03-22 Version : 1.2.0 - - initSmartBlocks() function added to simplfy startup process + - initcezerioBlocks() function added to simplfy startup process Date : 2017-03-23 Version : 1.2.1 - minor change; timer and can interrupt definitions moved to - "SmartBlockFunctions.h" from "SmartBlockFunctions.cpp" + "cezerioBlocks.h" from "cezerioBlocks.cpp" Date : 2017-03-30 Version : 1.2.2 - - new blocks and related functions added (TILT, COLOUR, SLIDE, FOLLOW, BIRRR) + - new blocks and related functions added (TILT, COLOUR, SLIDE, FOLLOW, BIRRR) Date : 2017-04-03 Version : 1.3.0 @@ -43,7 +43,7 @@ - new functions added for bluetooth communication (DataTransferFunctions) - new example sketch: SendReceiveBluetooth.ino - + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either @@ -60,7 +60,7 @@ 1301 USA */ -#include "SmartBlockFunctions.h" +#include "cezerioBlocks.h" #include "SoftwareSerial.h" #include "DataTransferFunctions.h" @@ -75,30 +75,30 @@ SoftwareSerial theSmartBlue(8, 9); // Set Software TX-RX to pins 8-9, instan capturedPacketType capturedPacket; /********************************************************************************************************* - * INIT FUNCTIONS + * INIT FUNCTIONS *********************************************************************************************************/ /** - * @brief Initialization for the blocks to be ready for operation + * @brief Initialization for the blocks to be ready for operation * @param None * @retval None */ -void initSmartBlocks(void) +void initcezerioBlocks(void) { Serial.begin(UART_BAUD_RATE); - + // Initialize MCP2515 running at 16MHz with a baudrate of 1000kb/s and the masks and filters disabled. if(CAN.begin(MCP_ANY, CAN_1000KBPS, MCP_16MHZ) == CAN_OK) Serial.println("MCP2515 Initialized Successfully!"); else Serial.println("Error Initializing MCP2515..."); - + CAN.setMode(MCP_NORMAL); // Set operation mode to normal so the MCP2515 sends acks to received data. - + #if defined(CAN_RECEIVE_INTERRUPT_ENABLE) pinMode(CAN_INT, INPUT); // Configuring pin for /INT input -#endif +#endif Serial.println("MCP2515 Library Receive Example..."); @@ -117,7 +117,7 @@ void initSmartBlocks(void) } /** - * @brief Initialization for BLUE BLOCK to be ready for operation + * @brief Initialization for BLUE BLOCK to be ready for operation * @param None * @retval None */ @@ -127,12 +127,12 @@ void initSmartBlue(void) } /********************************************************************************************************* - * BLE FUNCTIONS + * BLE FUNCTIONS *********************************************************************************************************/ /** - * @brief Get data from bluetooth device + * @brief Get data from bluetooth device * @param None * @retval None */ @@ -148,12 +148,12 @@ void getSmartBlueData(void) } /** - * @brief Send data to bluetooth device + * @brief Send data to bluetooth device * @param None * @retval None */ void sendSmartBlueData(unsigned char robotID, unsigned char packetID, unsigned char data) -{ +{ theSmartBlue.write('$'); theSmartBlue.write(robotID); theSmartBlue.write(packetID); @@ -162,7 +162,7 @@ void sendSmartBlueData(unsigned char robotID, unsigned char packetID, unsigned c } /** - * @brief Send Roller data to bluetooth device + * @brief Send Roller data to bluetooth device * @param None * @retval None */ @@ -172,7 +172,7 @@ void sendRollerData(unsigned char packetID, unsigned char data) } /** - * @brief Send Chariot data to bluetooth device + * @brief Send Chariot data to bluetooth device * @param None * @retval None */ @@ -182,7 +182,7 @@ void sendChariotData(unsigned char packetID, unsigned char data) } /** - * @brief Send Sumo data to bluetooth device + * @brief Send Sumo data to bluetooth device * @param None * @retval None */ @@ -192,7 +192,7 @@ void sendSumoData(unsigned char packetID, unsigned char data) } /** - * @brief Send Balance data to bluetooth device + * @brief Send Balance data to bluetooth device * @param None * @retval None */ @@ -202,7 +202,7 @@ void sendBalanceData(unsigned char packetID, unsigned char data) } /** - * @brief Send Windmill data to bluetooth device + * @brief Send Windmill data to bluetooth device * @param None * @retval None */ @@ -212,7 +212,7 @@ void sendWindmillData(unsigned char packetID, unsigned char data) } /** - * @brief Send FlyingCar data to bluetooth device + * @brief Send FlyingCar data to bluetooth device * @param None * @retval None */ @@ -222,7 +222,7 @@ void sendFlyingCarData(unsigned char packetID, unsigned char data) } /** - * @brief Send Spindle data to bluetooth device + * @brief Send Spindle data to bluetooth device * @param None * @retval None */ @@ -232,7 +232,7 @@ void sendSpindleData(unsigned char packetID, unsigned char data) } /** - * @brief Send Truck data to bluetooth device + * @brief Send Truck data to bluetooth device * @param None * @retval None */ @@ -242,7 +242,7 @@ void sendTruckData(unsigned char packetID, unsigned char data) } /** - * @brief Send Tank data to bluetooth device + * @brief Send Tank data to bluetooth device * @param None * @retval None */ @@ -252,7 +252,7 @@ void sendTankData(unsigned char packetID, unsigned char data) } /** - * @brief Send LineTracker data to bluetooth device + * @brief Send LineTracker data to bluetooth device * @param None * @retval None */ @@ -262,7 +262,7 @@ void sendLineTrackerData(unsigned char packetID, unsigned char data) } /** - * @brief Send Arm data to bluetooth device + * @brief Send Arm data to bluetooth device * @param None * @retval None */ @@ -272,7 +272,7 @@ void sendArmData(unsigned char packetID, unsigned char data) } /** - * @brief Send Loader data to bluetooth device + * @brief Send Loader data to bluetooth device * @param None * @retval None */ @@ -282,7 +282,7 @@ void sendLoaderData(unsigned char packetID, unsigned char data) } /** - * @brief Send Snake data to bluetooth device + * @brief Send Snake data to bluetooth device * @param None * @retval None */ @@ -292,7 +292,7 @@ void sendSnakeData(unsigned char packetID, unsigned char data) } /** - * @brief Send Excavator data to bluetooth device + * @brief Send Excavator data to bluetooth device * @param None * @retval None */ @@ -302,7 +302,7 @@ void sendExcavatorData(unsigned char packetID, unsigned char data) } /** - * @brief Send Mazer data to bluetooth device + * @brief Send Mazer data to bluetooth device * @param None * @retval None */ @@ -312,11 +312,11 @@ void sendMazerData(unsigned char packetID, unsigned char data) } /********************************************************************************************************* - * GENERIC FUNCTIONS + * GENERIC FUNCTIONS *********************************************************************************************************/ /** - * @brief Sends data request for input blocks + * @brief Sends data request for input blocks * @param INPUT BLOCK MESSAGE IDs * @retval None */ @@ -327,14 +327,14 @@ void createDataRequestPacket(unsigned int inputBlockMessageId) } /** - * @brief Reads values from input blocks and drives + * @brief Reads values from input blocks and drives output blocks with these data based on message IDs * @param None * @retval None */ void getInputDataAndDriveOutput(void) { - unsigned char motorSpeed = 0; + unsigned char motorSpeed = 0; unsigned char motorAngle = 0; unsigned char ledState = 0; unsigned char redLedState = 0; @@ -342,89 +342,89 @@ void getInputDataAndDriveOutput(void) unsigned char blueLedState = 0; unsigned char buzzerState = 0; unsigned char barGraphData = 0; - + CAN.readMsgBuf(&rxId, &len, rxBuf); // Read data: len = data length, buf = data byte(s) - + switch(rxId) { case MESSAGE_ID_BALANCE_BLOCK: - + break; - + case MESSAGE_ID_BALANCE_BLOCK + 1: - + break; - + case MESSAGE_ID_DETECT_BLOCK: - + break; - + case MESSAGE_ID_DETECT_BLOCK + 1: - + break; - + case MESSAGE_ID_EYE_BLOCK: - + break; - + case MESSAGE_ID_EYE_BLOCK + 1: - + break; - + case MESSAGE_ID_GESTURE_BLOCK: - + break; - + case MESSAGE_ID_GESTURE_BLOCK + 1: - + break; - + case MESSAGE_ID_KNOB_BLOCK: - + break; - + case MESSAGE_ID_KNOB_BLOCK + 1: - + break; - + case MESSAGE_ID_MIC_BLOCK: - + break; - + case MESSAGE_ID_MIC_BLOCK + 1: - + break; - + case MESSAGE_ID_PHOTO_BLOCK: - + break; - + case MESSAGE_ID_PHOTO_BLOCK + 1: - + break; - + case MESSAGE_ID_TEMP_BLOCK: - + break; - + case MESSAGE_ID_TEMP_BLOCK + 1: - + break; - + default: break; } } /** - * @brief Converts ASCII numbers to hex (integer value) + * @brief Converts ASCII numbers to hex (integer value) * @param Captured ASCII data * @retval Converted hex value */ unsigned char asciiToHex(unsigned char asciiData) { unsigned char hexData = 0; - + if((asciiData >= 0x30) && (asciiData <= 0x39)) { hexData = asciiData - 0x30; @@ -434,7 +434,7 @@ unsigned char asciiToHex(unsigned char asciiData) } /** - * @brief Converts hex (integer value) numbers to ASCII + * @brief Converts hex (integer value) numbers to ASCII * @param Captured hex data * @retval Converted ASCII value */ @@ -451,7 +451,7 @@ unsigned char hexToAscii(unsigned char hexData) } /********************************************************************************************************* - * INPUT FUNCTIONS + * INPUT FUNCTIONS *********************************************************************************************************/ /** @@ -462,14 +462,14 @@ unsigned char hexToAscii(unsigned char hexData) int* getAcc(unsigned int balanceBlockID) { createDataRequestPacket(balanceBlockID); - + CAN.readMsgBuf(&rxId, &len, rxBuf); // Read data: len = data length, buf = data byte(s) CAN.readMsgBuf(&rxId, &len, rx2Buf); // Read data: len = data length, buf = data byte(s) static int accData[3]; accData[0] = (rxBuf[3] << 8) + rxBuf[4]; accData[1] = (rxBuf[5] << 8) + rxBuf[6]; accData[2] = (rxBuf[7] << 8) + rx2Buf[0]; - + return accData; } @@ -481,14 +481,14 @@ int* getAcc(unsigned int balanceBlockID) int* getGyro(unsigned int balanceBlockID) { createDataRequestPacket(balanceBlockID); - + CAN.readMsgBuf(&rxId, &len, rxBuf); // Read data: len = data length, buf = data byte(s) CAN.readMsgBuf(&rxId, &len, rx2Buf); // Read data: len = data length, buf = data byte(s) static int gyroData[3]; gyroData[0] = (rx2Buf[1] << 8) + rx2Buf[2]; gyroData[1] = (rx2Buf[3] << 8) + rx2Buf[4]; gyroData[2] = (rx2Buf[5] << 8) + rx2Buf[6]; - + return gyroData; } @@ -500,10 +500,10 @@ int* getGyro(unsigned int balanceBlockID) unsigned char getDetect(unsigned int detectBlockID) { createDataRequestPacket(detectBlockID); - + CAN.readMsgBuf(&rxId, &len, rxBuf); // Read data: len = data length, buf = data byte(s) unsigned char irData = rxBuf[3]; - + return irData; } @@ -515,10 +515,10 @@ unsigned char getDetect(unsigned int detectBlockID) unsigned char getEye(unsigned int eyeBlockID) { createDataRequestPacket(eyeBlockID); - + CAN.readMsgBuf(&rxId, &len, rxBuf); // Read data: len = data length, buf = data byte(s) unsigned char ultrasonicData = rxBuf[3]; - + return ultrasonicData; } @@ -530,10 +530,10 @@ unsigned char getEye(unsigned int eyeBlockID) unsigned char getGesture(unsigned int gestureBlockID) { createDataRequestPacket(gestureBlockID); - + CAN.readMsgBuf(&rxId, &len, rxBuf); // Read data: len = data length, buf = data byte(s) unsigned char pirData = rxBuf[3]; - + return pirData; } @@ -545,10 +545,10 @@ unsigned char getGesture(unsigned int gestureBlockID) unsigned char getKnob(unsigned int knobBlockID) { createDataRequestPacket(knobBlockID); - + CAN.readMsgBuf(&rxId, &len, rxBuf); // Read data: len = data length, buf = data byte(s) unsigned char knobData = rxBuf[3]; - + return knobData; } @@ -560,10 +560,10 @@ unsigned char getKnob(unsigned int knobBlockID) unsigned char getMic(unsigned int micBlockID) { createDataRequestPacket(micBlockID); - + CAN.readMsgBuf(&rxId, &len, rxBuf); // Read data: len = data length, buf = data byte(s) unsigned char micData = rxBuf[3]; - + return micData; } @@ -575,10 +575,10 @@ unsigned char getMic(unsigned int micBlockID) unsigned char getPhoto(unsigned int photoBlockID) { createDataRequestPacket(photoBlockID); - + CAN.readMsgBuf(&rxId, &len, rxBuf); // Read data: len = data length, buf = data byte(s) unsigned char photoData = rxBuf[3]; - + return photoData; } @@ -590,10 +590,10 @@ unsigned char getPhoto(unsigned int photoBlockID) unsigned char getTemp(unsigned int tempBlockID) { createDataRequestPacket(tempBlockID); - + CAN.readMsgBuf(&rxId, &len, rxBuf); // Read data: len = data length, buf = data byte(s) unsigned char tempData = rxBuf[3]; - + return tempData; } @@ -605,10 +605,10 @@ unsigned char getTemp(unsigned int tempBlockID) unsigned char getTilt(unsigned int tiltBlockID) { createDataRequestPacket(tiltBlockID); - + CAN.readMsgBuf(&rxId, &len, rxBuf); // Read data: len = data length, buf = data byte(s) unsigned char tiltData = rxBuf[3]; - + return tiltData; } @@ -620,10 +620,10 @@ unsigned char getTilt(unsigned int tiltBlockID) //unsigned char getTemp(unsigned int tempBlockID) //{ // createDataRequestPacket(tempBlockID); -// +// // CAN.readMsgBuf(&rxId, &len, rxBuf); // Read data: len = data length, buf = data byte(s) // unsigned char tempData = rxBuf[3]; -// +// // return tempData; //} @@ -635,10 +635,10 @@ unsigned char getTilt(unsigned int tiltBlockID) unsigned char getSlide(unsigned int slideBlockID) { createDataRequestPacket(slideBlockID); - + CAN.readMsgBuf(&rxId, &len, rxBuf); // Read data: len = data length, buf = data byte(s) unsigned char sliderData = rxBuf[3]; - + return sliderData; } @@ -650,20 +650,20 @@ unsigned char getSlide(unsigned int slideBlockID) unsigned char getFollow(unsigned int followBlockID) { createDataRequestPacket(followBlockID); - + CAN.readMsgBuf(&rxId, &len, rxBuf); // Read data: len = data length, buf = data byte(s) unsigned char irData = rxBuf[3]; - + return irData; } /********************************************************************************************************* - * OUTPUT FUNCTIONS + * OUTPUT FUNCTIONS *********************************************************************************************************/ /** * @brief Sets DC motor speed and direction values for 360 BLOCK - * @param MESSAGE_ID_360_BLOCK + * @param MESSAGE_ID_360_BLOCK motorDirection : forward or backward motorSpeed : PWM value (0x00 - 0xFF) motorEnable : enable or disable @@ -678,7 +678,7 @@ void set360(unsigned int motor360BlockID, unsigned char motorDirection, unsigned /** * @brief Sets buzzer state for BIPP BLOCK * @param MESSAGE_ID_BIPP_BLOCK - buzzerState : "0" or "1" + buzzerState : "0" or "1" * @retval None */ void setBipp(unsigned int bippBlockID, unsigned char buzzerState) @@ -717,7 +717,7 @@ void setGrip(unsigned int gripBlockID, unsigned char motorAngle, unsigned char m /** * @brief Sets bar graph level value for LEVEL BLOCK * @param MESSAGE_ID_LEVEL_BLOCK - barGraphData : 0x00 - 0xFF + barGraphData : 0x00 - 0xFF * @retval None */ void setLevel(unsigned int levelBlockID, unsigned char barGraphData) @@ -753,7 +753,7 @@ void setLink(unsigned int linkBlockID, unsigned char motorAngle, unsigned char m /** * @brief Sets DC motor speed and direction values for MOTION BLOCK - * @param MESSAGE_ID_MOTION_BLOCK + * @param MESSAGE_ID_MOTION_BLOCK motorDdirection : forward or backward motorSpeed : PWM value (0x00 - 0xFF) motorEnable : enable or disable @@ -767,7 +767,7 @@ void setMotion(unsigned int motionBlockID, unsigned char motorDirection, unsigne /** * @brief Sets DC motor speed and direction values for ROLL BLOCK - * @param MESSAGE_ID_ROLL_BLOCK + * @param MESSAGE_ID_ROLL_BLOCK motorDdirection : forward or backward motorSpeed : PWM value (0x00 - 0xFF) motorEnable : enable or disable @@ -781,7 +781,7 @@ void setRoll(unsigned int rollBlockID, unsigned char motorDirection, unsigned ch /** * @brief Sets DC motor speed and direction values for BIRRR BLOCK - * @param MESSAGE_ID_BIRRR_BLOCK + * @param MESSAGE_ID_BIRRR_BLOCK motorDdirection : forward or backward motorSpeed : PWM value (0x00 - 0xFF) motorEnable : enable or disable diff --git a/libraries/CezerioBlocks/src/SmartBlockFunctions.h b/libraries/CezerioBlocks/src/cezerioBlocks.h similarity index 96% rename from libraries/CezerioBlocks/src/SmartBlockFunctions.h rename to libraries/CezerioBlocks/src/cezerioBlocks.h index 3cae861..0a497d4 100644 --- a/libraries/CezerioBlocks/src/SmartBlockFunctions.h +++ b/libraries/CezerioBlocks/src/cezerioBlocks.h @@ -1,7 +1,7 @@ /* - SmartBlockFunctions.h + cezerioBlocks.h 2017 Copyright (c) RFtek Electronics Ltd. All right reserved. - + Authors : Huseyin Ulvi AYDOGMUS, Ozgur BOSTAN Date : 2017-03-20 This library is free software; you can redistribute it and/or @@ -19,8 +19,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110- 1301 USA */ -#ifndef SMARTBLOCKFUNCTIONS_H_ -#define SMARTBLOCKFUNCTIONS_H_ +#ifndef CEZERIOBLOCKS_H_ +#define CEZERIOBLOCKS_H_ #include "mcp_can.h" @@ -74,26 +74,26 @@ #define MESSAGE_ID_LEVEL_BLOCK 0x110 #define MESSAGE_ID_LIGHT_BLOCK 0x120 #define MESSAGE_ID_LINK_BLOCK 0x130 -#define MESSAGE_ID_MOTION_BLOCK 0x140 +#define MESSAGE_ID_MOTION_BLOCK 0x140 #define MESSAGE_ID_ROLL_BLOCK 0x150 #define MESSAGE_ID_BIRRR_BLOCK 0x160 /********************************************************************************************************* - * Variables + * Variables *********************************************************************************************************/ /********************************************************************************************************* - * SmartBlockFunctions + * Functions *********************************************************************************************************/ -/* GENERIC FUNCTIONS */ +/* GENERIC FUNCTIONS */ void createDataRequestPacket(unsigned int blockMessageId); void getInputDataAndDriveOutput(void); unsigned char asciiToHex(unsigned char asciiData); unsigned char hexToAscii(unsigned char hexData); /* INIT FUNCTIONS */ -void initSmartBlocks(void); +void initcezerioBlocks(void); void initSmartBlue(void); /* BLE FUNCTIONS */ From a29ff5c0062c1dd3fe853dbd94689bb8796c13f4 Mon Sep 17 00:00:00 2001 From: Dogus Cendek Date: Wed, 14 Jun 2023 19:22:43 +0300 Subject: [PATCH 12/18] Clear Code --- variants/cezerioblocks/pins_arduino.h | 81 --------------------------- 1 file changed, 81 deletions(-) diff --git a/variants/cezerioblocks/pins_arduino.h b/variants/cezerioblocks/pins_arduino.h index 240caf1..47da602 100644 --- a/variants/cezerioblocks/pins_arduino.h +++ b/variants/cezerioblocks/pins_arduino.h @@ -1,25 +1,3 @@ -/* - pins_arduino.h - Pin definition functions for Arduino - Part of Arduino - http://www.arduino.cc/ - - Copyright (c) 2007 David A. Mellis - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General - Public License along with this library; if not, write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA -*/ - #ifndef Pins_Arduino_h #define Pins_Arduino_h @@ -80,49 +58,6 @@ static const uint8_t A7 = PIN_A7; #ifdef ARDUINO_MAIN -// On the Arduino board, digital pins are also used -// for the analog output (software PWM). Analog input -// pins are a separate set. - -// ATMEL ATMEGA8 & 168 / ARDUINO -// -// +-\/-+ -// PC6 1| |28 PC5 (AI 5) -// (D 0) PD0 2| |27 PC4 (AI 4) -// (D 1) PD1 3| |26 PC3 (AI 3) -// (D 2) PD2 4| |25 PC2 (AI 2) -// PWM+ (D 3) PD3 5| |24 PC1 (AI 1) -// (D 4) PD4 6| |23 PC0 (AI 0) -// VCC 7| |22 GND -// GND 8| |21 AREF -// PB6 9| |20 AVCC -// PB7 10| |19 PB5 (D 13) -// PWM+ (D 5) PD5 11| |18 PB4 (D 12) -// PWM+ (D 6) PD6 12| |17 PB3 (D 11) PWM -// (D 7) PD7 13| |16 PB2 (D 10) PWM -// (D 8) PB0 14| |15 PB1 (D 9) PWM -// +----+ -// -// (PWM+ indicates the additional PWM pins on the ATmega168.) - -// ATMEL ATMEGA1280 / ARDUINO -// -// 0-7 PE0-PE7 works -// 8-13 PB0-PB5 works -// 14-21 PA0-PA7 works -// 22-29 PH0-PH7 works -// 30-35 PG5-PG0 works -// 36-43 PC7-PC0 works -// 44-51 PJ7-PJ0 works -// 52-59 PL7-PL0 works -// 60-67 PD7-PD0 works -// A0-A7 PF0-PF7 -// A8-A15 PK0-PK7 - - -// these arrays map port names (e.g. port B) to the -// appropriate addresses for various functions (e.g. reading -// and writing) const uint16_t PROGMEM port_to_mode_PGM[] = { NOT_A_PORT, NOT_A_PORT, @@ -230,24 +165,8 @@ const uint8_t PROGMEM digital_pin_to_timer_PGM[] = { NOT_ON_TIMER, NOT_ON_TIMER, }; - #endif -// These serial port names are intended to allow libraries and architecture-neutral -// sketches to automatically default to the correct port name for a particular type -// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, -// the first hardware serial port whose RX/TX pins are not dedicated to another use. -// -// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor -// -// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial -// -// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library -// -// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. -// -// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX -// pins are NOT connected to anything by default. #define SERIAL_PORT_MONITOR Serial #define SERIAL_PORT_HARDWARE Serial From 58c7b6307b7e4ea58ef7d8097c8878621964babe Mon Sep 17 00:00:00 2001 From: Dogus Cendek Date: Wed, 14 Jun 2023 19:23:33 +0300 Subject: [PATCH 13/18] Change Version and Update Brand Change Version and Update Brand --- boards.txt | 2 +- platform.txt | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/boards.txt b/boards.txt index 8deea83..fc3d2b5 100644 --- a/boards.txt +++ b/boards.txt @@ -1,4 +1,4 @@ -# See: https://arduino.github.io/arduino-cli/latest/platform-specification/ +# See: https://github.com/cezer-io/cezerio-blocks-arduino ############################################################## diff --git a/platform.txt b/platform.txt index df5ddb7..d6cefcd 100644 --- a/platform.txt +++ b/platform.txt @@ -1,12 +1,12 @@ -# Arduino AVR Core and platform. +# cezerio Blocks # ------------------------------ # # For more info: -# https://arduino.github.io/arduino-cli/latest/platform-specification/ +# https://github.com/cezer-io/cezerio-blocks-arduino -name=Arduino AVR Boards -version=1.8.6 +name=cezerio Blocks +version=1.0.1 # AVR compile variables # --------------------- From 206d0f72aeab0383f2f29587face346a1be7f705 Mon Sep 17 00:00:00 2001 From: Dogus Cendek Date: Wed, 14 Jun 2023 19:25:21 +0300 Subject: [PATCH 14/18] Change "initcezerioBlocks" to "initCezerioBlocks" Change "initcezerioBlocks" to "initCezerioBlocks" --- .../CezerioBlocks/examples/Bluetooth/Chariot/Chariot.ino | 2 +- .../examples/Bluetooth/Flying_Car/Flying_Car.ino | 2 +- libraries/CezerioBlocks/examples/Bluetooth/Roller/Roller.ino | 2 +- .../Bluetooth/SendReceiveBluetooth/SendReceiveBluetooth.ino | 2 +- libraries/CezerioBlocks/examples/Bluetooth/Truck/Truck.ino | 2 +- .../CezerioBlocks/examples/Bluetooth/Windmill/Windmill.ino | 2 +- libraries/CezerioBlocks/examples/Level/Level.ino | 2 +- .../CezerioBlocks/examples/MotionDetector/MotionDetector.ino | 2 +- libraries/CezerioBlocks/examples/NightLamb/NightLamb.ino | 2 +- libraries/CezerioBlocks/examples/Runner/Runner.ino | 2 +- libraries/CezerioBlocks/examples/SendReceive/SendReceive.ino | 2 +- libraries/CezerioBlocks/examples/Sensormatic/Sensormatic.ino | 2 +- libraries/CezerioBlocks/examples/ShakyMic/ShakyMic.ino | 2 +- libraries/CezerioBlocks/keywords.txt | 2 +- libraries/CezerioBlocks/src/cezerioBlocks.cpp | 4 ++-- libraries/CezerioBlocks/src/cezerioBlocks.h | 2 +- 16 files changed, 17 insertions(+), 17 deletions(-) diff --git a/libraries/CezerioBlocks/examples/Bluetooth/Chariot/Chariot.ino b/libraries/CezerioBlocks/examples/Bluetooth/Chariot/Chariot.ino index de536ee..02dd5cb 100644 --- a/libraries/CezerioBlocks/examples/Bluetooth/Chariot/Chariot.ino +++ b/libraries/CezerioBlocks/examples/Bluetooth/Chariot/Chariot.ino @@ -10,7 +10,7 @@ extern capturedPacketType capturedPacket; void setup() { - initcezerioBlocks(); + initCezerioBlocks(); initSmartBlue(); } diff --git a/libraries/CezerioBlocks/examples/Bluetooth/Flying_Car/Flying_Car.ino b/libraries/CezerioBlocks/examples/Bluetooth/Flying_Car/Flying_Car.ino index cfdc686..16ebb46 100644 --- a/libraries/CezerioBlocks/examples/Bluetooth/Flying_Car/Flying_Car.ino +++ b/libraries/CezerioBlocks/examples/Bluetooth/Flying_Car/Flying_Car.ino @@ -10,7 +10,7 @@ extern capturedPacketType capturedPacket; void setup() { - initcezerioBlocks(); + initCezerioBlocks(); initSmartBlue(); } diff --git a/libraries/CezerioBlocks/examples/Bluetooth/Roller/Roller.ino b/libraries/CezerioBlocks/examples/Bluetooth/Roller/Roller.ino index dba6b39..4622fba 100644 --- a/libraries/CezerioBlocks/examples/Bluetooth/Roller/Roller.ino +++ b/libraries/CezerioBlocks/examples/Bluetooth/Roller/Roller.ino @@ -10,7 +10,7 @@ extern capturedPacketType capturedPacket; void setup() { - initcezerioBlocks(); + initCezerioBlocks(); initSmartBlue(); } diff --git a/libraries/CezerioBlocks/examples/Bluetooth/SendReceiveBluetooth/SendReceiveBluetooth.ino b/libraries/CezerioBlocks/examples/Bluetooth/SendReceiveBluetooth/SendReceiveBluetooth.ino index 3590c6f..163c0e2 100644 --- a/libraries/CezerioBlocks/examples/Bluetooth/SendReceiveBluetooth/SendReceiveBluetooth.ino +++ b/libraries/CezerioBlocks/examples/Bluetooth/SendReceiveBluetooth/SendReceiveBluetooth.ino @@ -7,7 +7,7 @@ extern capturedPacketType capturedPacket; void setup() { - initcezerioBlocks(); + initCezerioBlocks(); initSmartBlue(); } diff --git a/libraries/CezerioBlocks/examples/Bluetooth/Truck/Truck.ino b/libraries/CezerioBlocks/examples/Bluetooth/Truck/Truck.ino index 315ceae..330ed51 100644 --- a/libraries/CezerioBlocks/examples/Bluetooth/Truck/Truck.ino +++ b/libraries/CezerioBlocks/examples/Bluetooth/Truck/Truck.ino @@ -10,7 +10,7 @@ extern capturedPacketType capturedPacket; void setup() { - initcezerioBlocks(); + initCezerioBlocks(); initSmartBlue(); } diff --git a/libraries/CezerioBlocks/examples/Bluetooth/Windmill/Windmill.ino b/libraries/CezerioBlocks/examples/Bluetooth/Windmill/Windmill.ino index 51fd0cf..36b4a55 100644 --- a/libraries/CezerioBlocks/examples/Bluetooth/Windmill/Windmill.ino +++ b/libraries/CezerioBlocks/examples/Bluetooth/Windmill/Windmill.ino @@ -10,7 +10,7 @@ extern capturedPacketType capturedPacket; void setup() { - initcezerioBlocks(); + initCezerioBlocks(); initSmartBlue(); } diff --git a/libraries/CezerioBlocks/examples/Level/Level.ino b/libraries/CezerioBlocks/examples/Level/Level.ino index e016882..717315f 100644 --- a/libraries/CezerioBlocks/examples/Level/Level.ino +++ b/libraries/CezerioBlocks/examples/Level/Level.ino @@ -7,7 +7,7 @@ unsigned char timerFlag = 0; void setup() { - initcezerioBlocks(); + initCezerioBlocks(); } void loop() diff --git a/libraries/CezerioBlocks/examples/MotionDetector/MotionDetector.ino b/libraries/CezerioBlocks/examples/MotionDetector/MotionDetector.ino index a5d6bb7..91e72c7 100644 --- a/libraries/CezerioBlocks/examples/MotionDetector/MotionDetector.ino +++ b/libraries/CezerioBlocks/examples/MotionDetector/MotionDetector.ino @@ -7,7 +7,7 @@ unsigned char timerFlag = 0; void setup() { - initcezerioBlocks(); + initCezerioBlocks(); } void loop() diff --git a/libraries/CezerioBlocks/examples/NightLamb/NightLamb.ino b/libraries/CezerioBlocks/examples/NightLamb/NightLamb.ino index 02eaa18..4788d77 100644 --- a/libraries/CezerioBlocks/examples/NightLamb/NightLamb.ino +++ b/libraries/CezerioBlocks/examples/NightLamb/NightLamb.ino @@ -7,7 +7,7 @@ unsigned char timerFlag = 0; void setup() { - initcezerioBlocks(); + initCezerioBlocks(); } void loop() diff --git a/libraries/CezerioBlocks/examples/Runner/Runner.ino b/libraries/CezerioBlocks/examples/Runner/Runner.ino index 0f812ba..7352625 100644 --- a/libraries/CezerioBlocks/examples/Runner/Runner.ino +++ b/libraries/CezerioBlocks/examples/Runner/Runner.ino @@ -9,7 +9,7 @@ unsigned char timerFlag = 0; void setup() { - initcezerioBlocks(); + initCezerioBlocks(); } void loop() diff --git a/libraries/CezerioBlocks/examples/SendReceive/SendReceive.ino b/libraries/CezerioBlocks/examples/SendReceive/SendReceive.ino index 5742521..0d14d2d 100644 --- a/libraries/CezerioBlocks/examples/SendReceive/SendReceive.ino +++ b/libraries/CezerioBlocks/examples/SendReceive/SendReceive.ino @@ -4,7 +4,7 @@ unsigned char timerFlag = 0; void setup() { - initcezerioBlocks(); + initCezerioBlocks(); } void loop() diff --git a/libraries/CezerioBlocks/examples/Sensormatic/Sensormatic.ino b/libraries/CezerioBlocks/examples/Sensormatic/Sensormatic.ino index 0171afd..1e96ad9 100644 --- a/libraries/CezerioBlocks/examples/Sensormatic/Sensormatic.ino +++ b/libraries/CezerioBlocks/examples/Sensormatic/Sensormatic.ino @@ -12,7 +12,7 @@ unsigned char timerFlag = 0; void setup() { - initcezerioBlocks(); + initCezerioBlocks(); } void loop() diff --git a/libraries/CezerioBlocks/examples/ShakyMic/ShakyMic.ino b/libraries/CezerioBlocks/examples/ShakyMic/ShakyMic.ino index c8ee66e..f231c84 100644 --- a/libraries/CezerioBlocks/examples/ShakyMic/ShakyMic.ino +++ b/libraries/CezerioBlocks/examples/ShakyMic/ShakyMic.ino @@ -7,7 +7,7 @@ unsigned char timerFlag = 0; void setup() { - initcezerioBlocks(); + initCezerioBlocks(); } void loop() diff --git a/libraries/CezerioBlocks/keywords.txt b/libraries/CezerioBlocks/keywords.txt index b6e3010..8285a8f 100644 --- a/libraries/CezerioBlocks/keywords.txt +++ b/libraries/CezerioBlocks/keywords.txt @@ -1,6 +1,6 @@ createDataRequestPacket KEYWORD2 getInputDataAndDriveOutput KEYWORD2 -initcezerioBlocks KEYWORD2 +initCezerioBlocks KEYWORD2 initSmartBlue KEYWORD2 getAcc KEYWORD2 diff --git a/libraries/CezerioBlocks/src/cezerioBlocks.cpp b/libraries/CezerioBlocks/src/cezerioBlocks.cpp index 2ae2740..8ee484e 100644 --- a/libraries/CezerioBlocks/src/cezerioBlocks.cpp +++ b/libraries/CezerioBlocks/src/cezerioBlocks.cpp @@ -18,7 +18,7 @@ Date : 2017-03-22 Version : 1.2.0 - - initcezerioBlocks() function added to simplfy startup process + - initCezerioBlocks() function added to simplfy startup process Date : 2017-03-23 Version : 1.2.1 @@ -84,7 +84,7 @@ capturedPacketType capturedPacket; * @param None * @retval None */ -void initcezerioBlocks(void) +void initCezerioBlocks(void) { Serial.begin(UART_BAUD_RATE); diff --git a/libraries/CezerioBlocks/src/cezerioBlocks.h b/libraries/CezerioBlocks/src/cezerioBlocks.h index 0a497d4..7f51291 100644 --- a/libraries/CezerioBlocks/src/cezerioBlocks.h +++ b/libraries/CezerioBlocks/src/cezerioBlocks.h @@ -93,7 +93,7 @@ unsigned char asciiToHex(unsigned char asciiData); unsigned char hexToAscii(unsigned char hexData); /* INIT FUNCTIONS */ -void initcezerioBlocks(void); +void initCezerioBlocks(void); void initSmartBlue(void); /* BLE FUNCTIONS */ From 2511335b09e11fe0b874d8d0826998dace39068d Mon Sep 17 00:00:00 2001 From: Dogus Cendek Date: Thu, 15 Jun 2023 17:10:15 +0300 Subject: [PATCH 15/18] Add function and example to learn unknow ID Add function and example to learn unknow ID --- .../CezerioBlocks/examples/AskID/AskID.ino | 30 +++++++++++++++++++ libraries/CezerioBlocks/src/cezerioBlocks.cpp | 16 ++++++++++ libraries/CezerioBlocks/src/cezerioBlocks.h | 2 ++ 3 files changed, 48 insertions(+) create mode 100644 libraries/CezerioBlocks/examples/AskID/AskID.ino diff --git a/libraries/CezerioBlocks/examples/AskID/AskID.ino b/libraries/CezerioBlocks/examples/AskID/AskID.ino new file mode 100644 index 0000000..5eb3c77 --- /dev/null +++ b/libraries/CezerioBlocks/examples/AskID/AskID.ino @@ -0,0 +1,30 @@ +#include "cezerioBlocks.h" + +unsigned char timerFlag = 0; + +void setup() +{ + initCezerioBlocks(); +} + +void loop() +{ +#if defined(CAN_RECEIVE_INTERRUPT_ENABLE) + if(!digitalRead(CAN_INT)) + { + } +#endif + + if(timerFlag) + { + Serial.println(getBlockID(),HEX); + timerFlag = 0; + } +} + +#if defined(TIMER_INTERRUPT_ENABLE) +ISR(TIMER1_COMPA_vect) +{ + timerFlag = 1; +} +#endif diff --git a/libraries/CezerioBlocks/src/cezerioBlocks.cpp b/libraries/CezerioBlocks/src/cezerioBlocks.cpp index 8ee484e..40eee29 100644 --- a/libraries/CezerioBlocks/src/cezerioBlocks.cpp +++ b/libraries/CezerioBlocks/src/cezerioBlocks.cpp @@ -793,6 +793,22 @@ void setBirrr(unsigned int birrrBlockID, unsigned char motorDirection, unsigned CAN.sendMsgBuf(birrrBlockID, 0, 7, sendData); } +void createBlockDataRequestPacket(unsigned int requestMessageId) +{ + unsigned char sendData[4] = {SYNC_BYTE_START, 0x04, 0x00, SYNC_BYTE_STOP}; + CAN.sendMsgBuf(requestMessageId, 0, 4, sendData); +} + +uint16_t getBlockID() +{ + createBlockDataRequestPacket(MESSAGE_ID_REQUEST); + + CAN.readMsgBuf(&rxId, &len, rxBuf); // Read data: len = data length, buf = data byte(s) + unsigned char messageIDH = rxBuf[3]; + unsigned char messageIDL = rxBuf[4]; + + return (messageIDH << 8 | messageIDL); +} /********************************************************************************************************* * END FILE *********************************************************************************************************/ diff --git a/libraries/CezerioBlocks/src/cezerioBlocks.h b/libraries/CezerioBlocks/src/cezerioBlocks.h index 7f51291..5af7686 100644 --- a/libraries/CezerioBlocks/src/cezerioBlocks.h +++ b/libraries/CezerioBlocks/src/cezerioBlocks.h @@ -95,6 +95,8 @@ unsigned char hexToAscii(unsigned char hexData); /* INIT FUNCTIONS */ void initCezerioBlocks(void); void initSmartBlue(void); +void createBlockDataRequestPacket(unsigned int requestMessageId); +uint16_t getBlockID(); /* BLE FUNCTIONS */ void getSmartBlueData(void); From 0c1c5ee29f4e79a9fd64d055a8eca157944a0cbb Mon Sep 17 00:00:00 2001 From: Dogus Cendek Date: Thu, 15 Jun 2023 18:23:00 +0300 Subject: [PATCH 16/18] Delete Comments Delete Comments --- .../src/DataTransferFunctions.cpp | 76 +++--- .../CezerioBlocks/src/DataTransferFunctions.h | 27 +-- libraries/CezerioBlocks/src/cezerioBlocks.cpp | 62 ----- libraries/CezerioBlocks/src/cezerioBlocks.h | 21 -- libraries/CezerioBlocks/src/mcp_can.cpp | 223 ++++++++---------- libraries/CezerioBlocks/src/mcp_can.h | 45 +--- libraries/CezerioBlocks/src/mcp_can_dfs.h | 23 -- 7 files changed, 141 insertions(+), 336 deletions(-) diff --git a/libraries/CezerioBlocks/src/DataTransferFunctions.cpp b/libraries/CezerioBlocks/src/DataTransferFunctions.cpp index 3c1cd0d..5158c63 100644 --- a/libraries/CezerioBlocks/src/DataTransferFunctions.cpp +++ b/libraries/CezerioBlocks/src/DataTransferFunctions.cpp @@ -1,30 +1,8 @@ -/* - DataTransferFunctions.cpp - 2017 Copyright (c) RFtek Electronics Ltd. All right reserved. - - Authors : Huseyin Ulvi AYDOGMUS, Ozgur BOSTAN - Date : 2017-04-27 - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110- - 1301 USA -*/ - #include "DataTransferFunctions.h" unsigned char resolvePacketFlag = 0; /** - * @brief Capture packet from Serial Data + * @brief Capture packet from Serial Data * @param None * @retval None */ @@ -33,9 +11,9 @@ void captureData(capturedPacketType* capturedPacket, const unsigned char capturedDataSize) { unsigned char i = 0; - + for(i = 0; i < capturedDataSize; i++) - { + { switch(capturedPacket->data_capture_status) { case CAPTURE_START: @@ -50,15 +28,15 @@ void captureData(capturedPacketType* capturedPacket, capturedPacket->data_capture_status = CAPTURE_START; capturedPacket->data_counter = 0; } - + break; } - + case CAPTURE_ROBOT_ID: { capturedPacket->data_packet.robot_id = capturedData[i]; capturedPacket->data_capture_status = CAPTURE_PACKET_ID; - + break; } @@ -66,51 +44,51 @@ void captureData(capturedPacketType* capturedPacket, { capturedPacket->data_packet.packet_id = capturedData[i]; capturedPacket->data_capture_status = CAPTURE_DATA; - + break; } - + case CAPTURE_DATA: { capturedPacket->data_packet.data[capturedPacket->data_counter] = capturedData[i]; capturedPacket->data_counter++; - + if(capturedPacket->data_counter >= 1) { capturedPacket->data_capture_status = CAPTURE_STOP; } - + break; - } - + } + case CAPTURE_STOP: { if(STOP_BYTE == capturedData[i]) { capturedPacket->data_packet.stop_byte = capturedData[i]; - - // packet resolve + + // packet resolve //resolvePacket(&(capturedPacket->data_packet)); resolvePacketFlag = 1; } - + capturedPacket->data_capture_status = CAPTURE_START; capturedPacket->data_counter = 0; - + break; } - + default: { capturedPacket->data_capture_status = CAPTURE_START; capturedPacket->data_counter = 0; } } - } + } } /** - * @brief Pack data with a given format + * @brief Pack data with a given format * @param None * @retval None */ @@ -123,22 +101,22 @@ void packData(dataPacketType* data_packet, unsigned char robotID, unsigned char } /** - * @brief Resolve captured Serial Data + * @brief Resolve captured Serial Data * @param None * @retval None */ void resolvePacket(const dataPacketType* capturedPacket) { dataPacketType packet = {0}; - + switch(capturedPacket->packet_id) - { + { case BLE_ROBOT_NAME: - - break; + + break; case BLE_MOVE_FORWARD: - + break; case BLE_MOVE_BACKWARD: @@ -158,7 +136,7 @@ void resolvePacket(const dataPacketType* capturedPacket) break; case BLE_MOVE_FORWARD_LEFT: - + break; case BLE_MOVE_BACKWARD_RIGHT: @@ -334,7 +312,7 @@ void resolvePacket(const dataPacketType* capturedPacket) break; default: - + break; } } diff --git a/libraries/CezerioBlocks/src/DataTransferFunctions.h b/libraries/CezerioBlocks/src/DataTransferFunctions.h index 3dfa13e..49d8f75 100644 --- a/libraries/CezerioBlocks/src/DataTransferFunctions.h +++ b/libraries/CezerioBlocks/src/DataTransferFunctions.h @@ -1,24 +1,3 @@ -/* - DataTransferFunctions.h - 2017 Copyright (c) RFtek Electronics Ltd. All right reserved. - - Authors : Huseyin Ulvi AYDOGMUS, Ozgur BOSTAN - Date : 2017-04-27 - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110- - 1301 USA -*/ #ifndef DATATRANSFERFUNCTIONS_H_ #define DATATRANSFERFUNCTIONS_H_ @@ -56,7 +35,7 @@ enum dataRobotIDs ARM, LOADER, SNAKE, - EXCAVATOR, + EXCAVATOR, MAZER }; @@ -115,7 +94,7 @@ enum dataPacketIDs }; /********************************************************************************************************* - * Structs + * Structs *********************************************************************************************************/ typedef struct @@ -135,7 +114,7 @@ typedef struct } capturedPacketType; /********************************************************************************************************* - * DataTransferFunctions + * DataTransferFunctions *********************************************************************************************************/ diff --git a/libraries/CezerioBlocks/src/cezerioBlocks.cpp b/libraries/CezerioBlocks/src/cezerioBlocks.cpp index 40eee29..2e838e9 100644 --- a/libraries/CezerioBlocks/src/cezerioBlocks.cpp +++ b/libraries/CezerioBlocks/src/cezerioBlocks.cpp @@ -1,65 +1,3 @@ -/* - cezerioBlocks.cpp - 2017 Copyright (c) RFtek Electronics Ltd. All right reserved. - - Authors : Huseyin Ulvi AYDOGMUS, Ozgur BOSTAN - Date : 2017-03-20 - Version : 1.0.0 - - generic function for data request - - generic function for data receive and data sent - - main functions for output blocks - - Date : 2017-03-21 - Version : 1.1.0 - - generic function for data request - - generic function for data receive and data sent - - main functions for output blocks (removed) - - block specific functions for both input and output blocks added - - Date : 2017-03-22 - Version : 1.2.0 - - initCezerioBlocks() function added to simplfy startup process - - Date : 2017-03-23 - Version : 1.2.1 - - minor change; timer and can interrupt definitions moved to - "cezerioBlocks.h" from "cezerioBlocks.cpp" - - Date : 2017-03-30 - Version : 1.2.2 - - new blocks and related functions added (TILT, COLOUR, SLIDE, FOLLOW, BIRRR) - - Date : 2017-04-03 - Version : 1.3.0 - - new library added for BLUE BLOCK (SoftwareSerial) - - Date : 2017-04-27 - Version : 1.4.0 - - new library added for bluetooth communication (DataTransferFunctions) - - functions: getSmartBlueData, sendSmartBlueData - - Date : 2017-04-28 - Version : 1.4.1 - - new functions added for bluetooth communication (DataTransferFunctions) - - new example sketch: SendReceiveBluetooth.ino - - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110- - 1301 USA -*/ - #include "cezerioBlocks.h" #include "SoftwareSerial.h" #include "DataTransferFunctions.h" diff --git a/libraries/CezerioBlocks/src/cezerioBlocks.h b/libraries/CezerioBlocks/src/cezerioBlocks.h index 5af7686..3dc9996 100644 --- a/libraries/CezerioBlocks/src/cezerioBlocks.h +++ b/libraries/CezerioBlocks/src/cezerioBlocks.h @@ -1,24 +1,3 @@ -/* - cezerioBlocks.h - 2017 Copyright (c) RFtek Electronics Ltd. All right reserved. - - Authors : Huseyin Ulvi AYDOGMUS, Ozgur BOSTAN - Date : 2017-03-20 - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110- - 1301 USA -*/ #ifndef CEZERIOBLOCKS_H_ #define CEZERIOBLOCKS_H_ diff --git a/libraries/CezerioBlocks/src/mcp_can.cpp b/libraries/CezerioBlocks/src/mcp_can.cpp index 1e166a8..404005d 100644 --- a/libraries/CezerioBlocks/src/mcp_can.cpp +++ b/libraries/CezerioBlocks/src/mcp_can.cpp @@ -1,26 +1,3 @@ -/* - mcp_can.cpp - 2012 Copyright (c) Seeed Technology Inc. All right reserved. - 2014 Copyright (c) Cory J. Fowler All Rights Reserved. - - Author: Loovee - Contributor: Cory J. Fowler - 2014-9-16 - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110- - 1301 USA -*/ #include "mcp_can.h" #define spi_readwrite SPI.transfer @@ -30,7 +7,7 @@ ** Function name: mcp2515_reset ** Descriptions: Performs a software reset *********************************************************************************************************/ -void MCP_CAN::mcp2515_reset(void) +void MCP_CAN::mcp2515_reset(void) { MCP2515_SELECT(); spi_readwrite(MCP_RESET); @@ -42,7 +19,7 @@ void MCP_CAN::mcp2515_reset(void) ** Function name: mcp2515_readRegister ** Descriptions: Read data register *********************************************************************************************************/ -INT8U MCP_CAN::mcp2515_readRegister(const INT8U address) +INT8U MCP_CAN::mcp2515_readRegister(const INT8U address) { INT8U ret; @@ -66,7 +43,7 @@ void MCP_CAN::mcp2515_readRegisterS(const INT8U address, INT8U values[], const I spi_readwrite(MCP_READ); spi_readwrite(address); // mcp2515 has auto-increment of address-pointer - for (i=0; i 0) { #if DEBUG_MODE - Serial.print("Entering Configuration Mode Failure...\r\n"); + Serial.print("Entering Configuration Mode Failure...\r\n"); #endif return res; } @@ -530,7 +507,7 @@ INT8U MCP_CAN::mcp2515_init(const INT8U canIDMode, const INT8U canSpeed, const I MCP_RXB_RX_ANY); break; /* The followingn two functions of the MCP2515 do not work, there is a bug in the silicon. - case (MCP_STD): + case (MCP_STD): mcp2515_modifyRegister(MCP_RXB0CTRL, MCP_RXB_RX_MASK | MCP_RXB_BUKT_MASK, MCP_RXB_RX_STD | MCP_RXB_BUKT_MASK ); @@ -538,7 +515,7 @@ INT8U MCP_CAN::mcp2515_init(const INT8U canIDMode, const INT8U canSpeed, const I MCP_RXB_RX_STD); break; - case (MCP_EXT): + case (MCP_EXT): mcp2515_modifyRegister(MCP_RXB0CTRL, MCP_RXB_RX_MASK | MCP_RXB_BUKT_MASK, MCP_RXB_RX_EXT | MCP_RXB_BUKT_MASK ); @@ -546,29 +523,29 @@ INT8U MCP_CAN::mcp2515_init(const INT8U canIDMode, const INT8U canSpeed, const I MCP_RXB_RX_EXT); break; */ - case (MCP_STDEXT): + case (MCP_STDEXT): mcp2515_modifyRegister(MCP_RXB0CTRL, MCP_RXB_RX_MASK | MCP_RXB_BUKT_MASK, MCP_RXB_RX_STDEXT | MCP_RXB_BUKT_MASK ); mcp2515_modifyRegister(MCP_RXB1CTRL, MCP_RXB_RX_MASK, MCP_RXB_RX_STDEXT); break; - + default: -#if DEBUG_MODE +#if DEBUG_MODE Serial.print("`Setting ID Mode Failure...\r\n"); -#endif +#endif return MCP2515_FAIL; break; -} +} - res = mcp2515_setCANCTRL_Mode(mcpMode); + res = mcp2515_setCANCTRL_Mode(mcpMode); if(res) { -#if DEBUG_MODE +#if DEBUG_MODE Serial.print("Returning to Previous Mode Failure...\r\n"); -#endif +#endif return res; } @@ -588,7 +565,7 @@ void MCP_CAN::mcp2515_write_id( const INT8U mcp_addr, const INT8U ext, const INT canid = (uint16_t)(id & 0x0FFFF); - if ( ext == 1) + if ( ext == 1) { tbufdata[MCP_EID0] = (INT8U) (canid & 0xFF); tbufdata[MCP_EID8] = (INT8U) (canid >> 8); @@ -598,14 +575,14 @@ void MCP_CAN::mcp2515_write_id( const INT8U mcp_addr, const INT8U ext, const INT tbufdata[MCP_SIDL] |= MCP_TXB_EXIDE_M; tbufdata[MCP_SIDH] = (INT8U) (canid >> 5 ); } - else + else { tbufdata[MCP_SIDH] = (INT8U) (canid >> 3 ); tbufdata[MCP_SIDL] = (INT8U) ((canid & 0x07 ) << 5); tbufdata[MCP_EID0] = 0; tbufdata[MCP_EID8] = 0; } - + mcp2515_setRegisterS( mcp_addr, tbufdata, 4 ); } @@ -620,7 +597,7 @@ void MCP_CAN::mcp2515_write_mf( const INT8U mcp_addr, const INT8U ext, const INT canid = (uint16_t)(id & 0x0FFFF); - if ( ext == 1) + if ( ext == 1) { tbufdata[MCP_EID0] = (INT8U) (canid & 0xFF); tbufdata[MCP_EID8] = (INT8U) (canid >> 8); @@ -630,7 +607,7 @@ void MCP_CAN::mcp2515_write_mf( const INT8U mcp_addr, const INT8U ext, const INT tbufdata[MCP_SIDL] |= MCP_TXB_EXIDE_M; tbufdata[MCP_SIDH] = (INT8U) (canid >> 5 ); } - else + else { tbufdata[MCP_EID0] = (INT8U) (canid & 0xFF); tbufdata[MCP_EID8] = (INT8U) (canid >> 8); @@ -638,7 +615,7 @@ void MCP_CAN::mcp2515_write_mf( const INT8U mcp_addr, const INT8U ext, const INT tbufdata[MCP_SIDL] = (INT8U) ((canid & 0x07) << 5); tbufdata[MCP_SIDH] = (INT8U) (canid >> 3 ); } - + mcp2515_setRegisterS( mcp_addr, tbufdata, 4 ); } @@ -657,7 +634,7 @@ void MCP_CAN::mcp2515_read_id( const INT8U mcp_addr, INT8U* ext, INT32U* id ) *id = (tbufdata[MCP_SIDH]<<3) + (tbufdata[MCP_SIDL]>>5); - if ( (tbufdata[MCP_SIDL] & MCP_TXB_EXIDE_M) == MCP_TXB_EXIDE_M ) + if ( (tbufdata[MCP_SIDL] & MCP_TXB_EXIDE_M) == MCP_TXB_EXIDE_M ) { /* extended id */ *id = (*id<<2) + (tbufdata[MCP_SIDL] & 0x03); @@ -676,9 +653,9 @@ void MCP_CAN::mcp2515_write_canMsg( const INT8U buffer_sidh_addr) INT8U mcp_addr; mcp_addr = buffer_sidh_addr; mcp2515_setRegisterS(mcp_addr+5, m_nDta, m_nDlc ); /* write data bytes */ - + if ( m_nRtr == 1) /* if RTR set bit in byte */ - m_nDlc |= MCP_RTR_MASK; + m_nDlc |= MCP_RTR_MASK; mcp2515_setRegister((mcp_addr+4), m_nDlc ); /* write the RTR and DLC */ mcp2515_write_id(mcp_addr, m_nExtFlg, m_nID ); /* write CAN id */ @@ -726,7 +703,7 @@ INT8U MCP_CAN::mcp2515_getNextFreeTXBuf(INT8U *txbuf_n) /* get N ctrlval = mcp2515_readRegister( ctrlregs[i] ); if ( (ctrlval & MCP_TXB_TXREQ_M) == 0 ) { *txbuf_n = ctrlregs[i]+1; /* return SIDH-address of Buffer*/ - + res = MCP2515_OK; return res; /* ! function exit */ } @@ -757,7 +734,7 @@ INT8U MCP_CAN::begin(INT8U idmodeset, INT8U speedset, INT8U clockset) res = mcp2515_init(idmodeset, speedset, clockset); if (res == MCP2515_OK) return CAN_OK; - + return CAN_FAILINIT; } @@ -774,11 +751,11 @@ INT8U MCP_CAN::init_Mask(INT8U num, INT8U ext, INT32U ulData) res = mcp2515_setCANCTRL_Mode(MODE_CONFIG); if(res > 0){ #if DEBUG_MODE - Serial.print("Entering Configuration Mode Failure...\r\n"); + Serial.print("Entering Configuration Mode Failure...\r\n"); #endif return res; } - + if (num == 0){ mcp2515_write_mf(MCP_RXM0SIDH, ext, ulData); @@ -787,11 +764,11 @@ INT8U MCP_CAN::init_Mask(INT8U num, INT8U ext, INT32U ulData) mcp2515_write_mf(MCP_RXM1SIDH, ext, ulData); } else res = MCP2515_FAIL; - + res = mcp2515_setCANCTRL_Mode(mcpMode); if(res > 0){ #if DEBUG_MODE - Serial.print("Entering Previous Mode Failure...\r\nSetting Mask Failure...\r\n"); + Serial.print("Entering Previous Mode Failure...\r\nSetting Mask Failure...\r\n"); #endif return res; } @@ -815,14 +792,14 @@ INT8U MCP_CAN::init_Mask(INT8U num, INT32U ulData) res = mcp2515_setCANCTRL_Mode(MODE_CONFIG); if(res > 0){ #if DEBUG_MODE - Serial.print("Entering Configuration Mode Failure...\r\n"); + Serial.print("Entering Configuration Mode Failure...\r\n"); #endif return res; } - + if((num & 0x80000000) == 0x80000000) ext = 1; - + if (num == 0){ mcp2515_write_mf(MCP_RXM0SIDH, ext, ulData); @@ -831,11 +808,11 @@ INT8U MCP_CAN::init_Mask(INT8U num, INT32U ulData) mcp2515_write_mf(MCP_RXM1SIDH, ext, ulData); } else res = MCP2515_FAIL; - + res = mcp2515_setCANCTRL_Mode(mcpMode); if(res > 0){ #if DEBUG_MODE - Serial.print("Entering Previous Mode Failure...\r\nSetting Mask Failure...\r\n"); + Serial.print("Entering Previous Mode Failure...\r\nSetting Mask Failure...\r\n"); #endif return res; } @@ -859,11 +836,11 @@ INT8U MCP_CAN::init_Filt(INT8U num, INT8U ext, INT32U ulData) if(res > 0) { #if DEBUG_MODE - Serial.print("Enter Configuration Mode Failure...\r\n"); + Serial.print("Enter Configuration Mode Failure...\r\n"); #endif return res; } - + switch( num ) { case 0: @@ -893,19 +870,19 @@ INT8U MCP_CAN::init_Filt(INT8U num, INT8U ext, INT32U ulData) default: res = MCP2515_FAIL; } - + res = mcp2515_setCANCTRL_Mode(mcpMode); if(res > 0) { #if DEBUG_MODE - Serial.print("Entering Previous Mode Failure...\r\nSetting Filter Failure...\r\n"); + Serial.print("Entering Previous Mode Failure...\r\nSetting Filter Failure...\r\n"); #endif return res; } #if DEBUG_MODE Serial.print("Setting Filter Successfull!\r\n"); #endif - + return res; } @@ -917,7 +894,7 @@ INT8U MCP_CAN::init_Filt(INT8U num, INT32U ulData) { INT8U res = MCP2515_OK; INT8U ext = 0; - + #if DEBUG_MODE Serial.print("Starting to Set Filter!\r\n"); #endif @@ -925,14 +902,14 @@ INT8U MCP_CAN::init_Filt(INT8U num, INT32U ulData) if(res > 0) { #if DEBUG_MODE - Serial.print("Enter Configuration Mode Failure...\r\n"); + Serial.print("Enter Configuration Mode Failure...\r\n"); #endif return res; } - + if((num & 0x80000000) == 0x80000000) ext = 1; - + switch( num ) { case 0: @@ -962,19 +939,19 @@ INT8U MCP_CAN::init_Filt(INT8U num, INT32U ulData) default: res = MCP2515_FAIL; } - + res = mcp2515_setCANCTRL_Mode(mcpMode); if(res > 0) { #if DEBUG_MODE - Serial.print("Entering Previous Mode Failure...\r\nSetting Filter Failure...\r\n"); + Serial.print("Entering Previous Mode Failure...\r\nSetting Filter Failure...\r\n"); #endif return res; } #if DEBUG_MODE Serial.print("Setting Filter Successfull!\r\n"); #endif - + return res; } @@ -991,7 +968,7 @@ INT8U MCP_CAN::setMsg(INT32U id, INT8U rtr, INT8U ext, INT8U len, INT8U *pData) m_nDlc = len; for(i = 0; i Date: Thu, 15 Jun 2023 18:23:15 +0300 Subject: [PATCH 17/18] Add IDs of cezerio blocks Add IDs of cezerio blocks --- README.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/README.md b/README.md index f7d1d64..f2cbfaf 100644 --- a/README.md +++ b/README.md @@ -13,3 +13,31 @@ JSON index file: `https://raw.githubusercontent.com/cezer-io/cezerio-blocks-ardu ### Development Status [![Release Version](https://img.shields.io/github/v/release/cezer-io/cezerio-blocks-arduino?color=880414)](https://github.com/cezer-io/cezerio-blocks-arduino/releases/latest/) [![Release Date](https://img.shields.io/github/release-date/cezer-io/cezerio-blocks-arduino?color=487c17)](https://github.com/cezer-io/cezerio-blocks-arduino/releases/latest/) [![Downloads](https://img.shields.io/github/downloads/cezer-io/cezerio-blocks-arduino/latest/total?color=167cc9)](https://github.com/cezer-io/cezerio-blocks-arduino/releases/latest/) [![Downloads](https://img.shields.io/github/downloads/cezer-io/cezerio-blocks-arduino/total?color=167cc9)](https://github.com/cezer-io/cezerio-blocks-arduino/releases/latest/) + +### IDs +Each input and output block has an ID to communicate with brain block. + + | ID | | + | :--- | :--- | + | BALANCE BLOCK | 0x010 | + | DETECT BLOCK | 0x020 | + | EYE BLOCK | 0x030 | + | GESTURE BLOCK | 0x040 | + | KNOB BLOCK | 0x050 | + | MIC BLOCK | 0x060 | + | PHOTO BLOCK | 0x070 | + | TEMP BLOCK | 0x080 | + | TILT BLOCK | 0x090 | + | COLOUR BLOCK | 0x0A0 | + | SLIDE BLOCK | 0x0B0 | + | FOLLOW BLOCK | 0x0C0 | + | 360 BLOCK | 0x0D0 | + | BIPP BLOCK | 0x0E0 | + | COLOR BLOCK | 0x0F0 | + | GRIPP BLOCK | 0x100 | + | LEVEL BLOCK | 0x110 | + | LIGHT BLOCK | 0x120 | + | LINK BLOCK | 0x130 | + | MOTION BLOCK | 0x140 | + | ROLL BLOCK | 0x150 | + | BIRRR BLOCK | 0x160 | From 15c2ccd3fca3240d9b4cd0a95d2780eb9adee329 Mon Sep 17 00:00:00 2001 From: Dogus Cendek Date: Thu, 15 Jun 2023 18:40:12 +0300 Subject: [PATCH 18/18] Update package_cezerio_blocks_index.json --- package_cezerio_blocks_index.json | 37 ++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/package_cezerio_blocks_index.json b/package_cezerio_blocks_index.json index 4e77cb4..5a95fd2 100644 --- a/package_cezerio_blocks_index.json +++ b/package_cezerio_blocks_index.json @@ -6,6 +6,41 @@ "websiteUrl": "https://github.com/cezer-io", "email": "hello@cezerio.com", "platforms": [ + { + "name": "cezerio Blocks", + "architecture": "avr", + "version": "1.0.1", + "category": "Contributed", + "url": "https://github.com/cezer-io/cezerio-blocks-arduino/archive/refs/tags/1.0.1.tar.gz", + "archiveFileName": "1.0.1.tar.gz", + "checksum": "SHA-256:bf917bcc4b7f24f45dc7858d43c90a5612fb3075634f71f1ef5b300ae4970b49", + "size": "7598796", + "help": { + "online": "" + }, + "boards": [ + { + "name": "cezerio Blocks" + } + ], + "help": { + "online": "https://github.com/cezer-io" + }, + "toolsDependencies": [ + { + "packager": "arduino", + "name": "avrdude", + "version": "6.3.0-arduino17" + }, + { + "packager": "arduino", + "name": "arduinoOTA", + "version": "1.3.0" + } + ], + "discoveryDependencies": [], + "monitorDependencies": [] + }, { "name": "cezerio Blocks", "architecture": "avr", @@ -40,7 +75,7 @@ ], "discoveryDependencies": [], "monitorDependencies": [] - } + } ], "tools": [ {