added radio transmit power
This commit is contained in:
parent
fb65711f08
commit
3c76e86cef
@ -82,4 +82,16 @@ namespace radio {
|
||||
//% blockId=radio_set_group block="set group %ID"
|
||||
export function setGroup(id: number) : void {
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the output power level of the transmitter to the given value.
|
||||
* @param power a value in the range 0..7, where 0 is the lowest power and 7 is the highest, eg: 7
|
||||
*/
|
||||
//% help=/functions/set-transmit-power
|
||||
//% shim=micro_bit::setTransmitPower
|
||||
//% weight=9
|
||||
//% blockId=radio_set_transmit_power block="set transmit power %power"
|
||||
export function setTransmitPower(power:number) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -445,6 +445,9 @@ namespace ks.rt.micro_bit {
|
||||
board().radio.setGroup(id);
|
||||
}
|
||||
|
||||
export function setTransmitPower(power: number) : void {
|
||||
board().radio.setTransmitPower(power);
|
||||
}
|
||||
|
||||
export function datagramSendNumbers(value0 : number, value1: number, value2: number, value3: number) : void {
|
||||
board().radio.datagram.send([value0, value1, value2, value3]);
|
||||
|
@ -98,6 +98,7 @@ namespace ks.rt.micro_bit {
|
||||
export class RadioBus {
|
||||
// uint8_t radioDefaultGroup = MICROBIT_RADIO_DEFAULT_GROUP;
|
||||
groupId = 0; // todo
|
||||
power = 0;
|
||||
datagram: RadioDatagram;
|
||||
|
||||
constructor(private runtime: Runtime) {
|
||||
@ -107,13 +108,19 @@ namespace ks.rt.micro_bit {
|
||||
setGroup(id: number) {
|
||||
this.groupId = id & 0xff; // byte only
|
||||
}
|
||||
|
||||
setTransmitPower(power: number) {
|
||||
this.power = Math.max(0, Math.min(7, power));
|
||||
}
|
||||
|
||||
broadcast(msg: number) {
|
||||
let ens = enums();
|
||||
Runtime.postMessage(<SimulatorEventBusMessage>{
|
||||
type: 'eventbus',
|
||||
id: ens.MES_BROADCAST_GENERAL_ID,
|
||||
eventid: msg
|
||||
eventid: msg,
|
||||
power: this.power,
|
||||
group: this.groupId
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user