Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added images/hardware/neo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/hw/neo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/hw_lite/chocolite.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/hw_lite/neo_lite.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
295 changes: 294 additions & 1 deletion src/playground/blocks/hardware/block_0uboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Entry.pyocoding = {
OLED: 241,
COM: 242,
NEOPIXELCOLOR: 243,

DOTMATRIX: 245,
},
duration: {
TIME_1ms: 1,
Expand Down Expand Up @@ -103,6 +103,10 @@ Entry.pyocoding.setLanguage = function() {
pyocoding_neopixel_all_led: '네오픽셀 %1 번에 LED R: %2 , G: %3 , B: %4 색을 밝기 %5 으로 켜기',
pyocoding_digital_pwm: '디지털 %1 번 핀을 %2 (으)로 정하기 %3',
pyocoding_set_tone: '디지털 %1 번 핀을 %2 음으로 %3 옥타브로 %4 만큼 연주하기 %5',
pyocoding_change_4095to255_value: '%1 값 %2을 %3로 변환하기',
pyocoding_change_analog_to_temperature_tc_value: '아날로그 온도 변환 %1',
pyocoding_get_touch_value : '터치 %1 센서값',
pyocoding_dotmatrix : '도트매트릭스 %1 번 배열에 %2 을 그리기',
},
},
en: {
Expand Down Expand Up @@ -137,6 +141,10 @@ Entry.pyocoding.setLanguage = function() {
pyocoding_neopixel_all_led: '디지털 %1 번 핀에 연결된 %2 번째 네오픽셀 LED R: %3 , G: %4 , B: %5 색으로 켜기',
pyocoding_digital_pwm: 'Digital %1 Pin %2 %3',
pyocoding_set_tone: 'Play tone pin %1 on note %2 octave %3 beat %4 %5',
pyocoding_change_4095to255_value: 'Analog 4095to255 %1',
pyocoding_change_analog_to_temperature_tc_value: 'Analog to Tc %1',
pyocoding_get_touch_value : 'touch %1 value',
pyocoding_dotmatrix : '도트매트릭스 %1 번 배열에 %2 을 그리기',
},
},
};
Expand All @@ -158,6 +166,10 @@ Entry.pyocoding.blockMenuBlocks = [
'pyocoding_neopixel_set',
'pyocoding_neopixel_led',
'pyocoding_neopixel_all_led',
'pyocoding_change_4095to255_value',
'pyocoding_change_analog_to_temperature_tc_value',
'pyocoding_get_touch_value',
'pyocoding_dotmatrix',

];

Expand Down Expand Up @@ -295,11 +307,151 @@ Entry.pyocoding.getBlocks = function() {
func: function (sprite, script) {
var port = script.getValue("PORT", script);
var ANALOG = Entry.hw.portData.ANALOG;
//console.log(port,ANALOG)
if (port[0] === "A")
port = port.substring(1)
return ANALOG ? ANALOG[port] || 0 : 0;
},
},
pyocoding_get_touch_value: {
color: EntryStatic.colorSet.block.default.HARDWARE,
outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
skeleton: 'basic_string_field',
statements: [],
events: {},
params: [
{
"type": "Dropdown",
"options": [
[ "A3", "3" ],
//[ "A5", "5" ],
],
"value": "3",
"fontSize": 11,
bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
},
],
def: {
params: [ null ],
"type": "pyocoding_get_touch_value"
},
isNotFor: [ '0uboard' ],
class: "SENSOR",
paramsKeyMap: {
"PORT": 0,
},
func: function (sprite, script) {
var port = script.getValue("PORT", script);
var ANALOG = Entry.hw.portData.ANALOG;
console.log(port,ANALOG)
if (port[0] === "A")
port = port.substring(1)
return ANALOG ? ANALOG[5] || 0 : 0;
},
},
pyocoding_change_4095to255_value: {
color: EntryStatic.colorSet.block.default.HARDWARE,
outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
skeleton: 'basic_string_field',
statements: [],
events: {},
params: [
{
"type": "Block",
"accept": "string"
},
{
"type": "Block",
"accept": "string"
},
{
"type": "Block",
"accept": "string"
},
],
def: {
params: [
{
"type": "text",
"params": [ "0" ]
},
{
"type": "text",
"params": [ "4095" ]
},
{
"type": "text",
"params": [ "255" ]
},
],
"type": "pyocoding_change_4095to255_value"
},
isNotFor: [ '0uboard' ],
class: "ext",
paramsKeyMap: {
"VALUE": 0,
"VALUE2": 1,
"VALUE3": 2,
},
func: function (sprite, script) {
var value = script.getNumberValue("VALUE");
var value2 = script.getNumberValue("VALUE2");
var value3 = script.getNumberValue("VALUE3");
console.log(value,value2,value3);
var dividedValue = Math.floor(value / (value2 / value3));

return dividedValue;
},
},
pyocoding_change_analog_to_temperature_tc_value: {
color: EntryStatic.colorSet.block.default.HARDWARE,
outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
skeleton: 'basic_string_field',
statements: [],
events: {},
params: [
{
"type": "Block",
"accept": "string"
},
],
def: {
params: [
{
"type": "text",
"params": [ "0" ]
},
null
],
"type": "pyocoding_change_analog_to_temperature_tc_value"
},
isNotFor: [ '0uboard' ],
class: "ext",
paramsKeyMap: {
"VALUE": 0,
},
func: function (sprite, script) {

var R1 = 10000;
var logR2, R2, T, Tc, Tf;
var c1 = 1.106836861e-03, c2 = 2.384641754e-04, c3 = 0.6507394466e-07;

var Vo = script.getNumberValue("VALUE");

R2 = R1 * ((4095.0 / Vo) - 1.0);
logR2 = Math.log(R2);
T = (1.0 / (c1 + c2*logR2 + c3*logR2*logR2*logR2));
Tc = T - 273.15; //섭씨
//Tf = (Tc * 9.0)/ 5.0 + 32.0; //화씨

// Print the result to the console
//console.log("vo:",Vo,"Tc:",Tc);

// You can return the value in Fahrenheit as well
return Tc;
},
},
pyocoding_get_port_number: {
color: EntryStatic.colorSet.block.default.HARDWARE,
outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
Expand Down Expand Up @@ -1388,6 +1540,147 @@ Entry.pyocoding.getBlocks = function() {
syntax: {
},
},
pyocoding_dotmatrix: {
color: EntryStatic.colorSet.block.default.HARDWARE,
outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
skeleton: 'basic',
statements: [],
params: [
{
"type": "Dropdown",
"options": [
["0","0"],
["1","1"],
["2","2"],
["3","3"],
["4","4"],
["5","5"],
["6","6"],
["7","7"],
],
"value":"0",
"fontSize":11,
bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
},
{
type: 'Block',
accept: 'string',
defaultType: 'number',
},
{
type: 'Block',
accept: 'string',
defaultType: 'number',
},
{
type: 'Block',
accept: 'string',
defaultType: 'number',
},
{
type: 'Block',
accept: 'string',
defaultType: 'number',
},
{
type: 'Indicator',
img: 'block_icon/hardware_icon.svg',
size: 12,
},
],
events: {},
def: {
params: [
null,
{
type: 'number',
params: ['00001111'],
},
{
type: 'number',
params: ['255'],
},
{
type: 'number',
params: ['255'],
},
{
type: 'number',
params: ['100'],
},
null,
],
type: 'pyocoding_dotmatrix',
},
paramsKeyMap: {
INDEX : 0,
RED: 1,
GREEN: 2,
BLUE: 3,
BRIG: 4,
},
class: 'neopixel',
isNotFor: ['0uboard'],
func(sprite, script) {
var port = script.getNumberValue("INDEX");
var red = script.getNumberValue("RED");
var green = script.getNumberValue("GREEN");
var blue = script.getNumberValue("BLUE");
var brig = script.getNumberValue("BRIG");
var mode = 3;

let str = parseInt(String(red), 2);
red = str;

if(red > 255) red=255;
console.log(red);


if (!script.isStart)
{

if(!Entry.hw.sendQueue['SET']) {
Entry.hw.sendQueue['SET'] = {};
}
var duration = Entry.Orange.duration.TIME_10ms;
script.isStart = true;
script.timeFlag = 1;

Entry.hw.sendQueue['SET'][port] = {
type: Entry.pyocoding.sensorTypes.DOTMATRIX,
data:
{
index : port,
mode: mode,
red: red,
green: green,
blue: blue,
brig: brig,
},
time: new Date().getTime()
};
setTimeout(function() {
script.timeFlag = 0;
}, duration );
return script;
}
else if (script.timeFlag == 1)
{
return script;
}
else
{
delete script.timeFlag;
delete script.isStart;

Entry.engine.isContinue = false;
return script.callReturn();
}
},
syntax: {
},
},
} //return
}; //function

Expand Down
Loading