pimatic / rfcontroljs

nodejs modul with protocol support for different 433mhz switches and weather stations for the RFControl Arduino library.
GNU General Public License v3.0
49 stars 54 forks source link

Support for Projector Screen iVisions Electro M #93

Closed rrooggiieerr closed 1 year ago

rrooggiieerr commented 8 years ago

Hi,

First of all thank you for creating and maintaining this great piece of software, I'm having a lot of fun with it as part of Pimatic.

I recently bought a projector screen, the iVisions Electro M. Most probably some re-branded screen as I can only find one shop on the internet who sells them under that name.

The screen comes with a 433mhz remote which is currently not supported by rfcontroljs.

This are the codes:

Screen up debug [pimatic-homeduino]: received: [ 199, 588, 824, 5164 ] 110011001010110100101101010100101011010100110010110100101100101010101010101010110010101010101010101011001011001011001011010100110123 debug [pimatic-homeduino]: data: "RF receive 588 199 824 5164 0 0 0 0 001100110101001011010010101011010100101011001101001011010011010101010101010101001101010101010101010100110100110100110100101011001023" debug [pimatic-homeduino]: received: [ 153, 217, 599, 5104 ] 221022102020221210202212121210202022121210221020221210202210212021212120202021221020212021212120202121202210221212102121202211212223 debug [pimatic-homeduino]: data: "RF receive 599 217 153 5104 0 0 0 0 001200120202001012020010101012020200101012001202001012020012010201010102020201001202010201010102020101020012001010120101020011010003"

Stop debug [pimatic-homeduino]: received: [ 154, 172, 240, 598, 5100 ] 332033203030332320303323232320303033232320332030332320303320303030303030303032332030313030303230303033203030332323203233232322313334 debug [pimatic-homeduino]: data: "RF receive 598 240 154 172 5100 0 0 0 001200120202001012020010101012020200101012001202001012020012020202020202020201001202030202020102020200120202001010120100101011030004"

Screen down debug [pimatic-homeduino]: received: [ 198, 589, 832, 5164 ] 110011001010110100101101010100101011010100110010110100101100101010101010101010110010101010101010101011001011001011001011010100110123 debug [pimatic-homeduino]: data: "RF receive 589 198 832 5164 0 0 0 0 001100110101001011010010101011010100101011001101001011010011010101010101010101001101010101010101010100110100110100110100101011001023" debug [pimatic-homeduino]: received: [ 199, 591, 5180 ] 110011001010110100101101010100101011010100110010110100101100101010101010101010110010101010101010101011001011001011001011010100110112 debug [pimatic-homeduino]: data: "RF receive 591 199 5180 0 0 0 0 0 001100110101001011010010101011010100101011001101001011010011010101010101010101001101010101010101010100110100110100110100101011001002"

Is it possible to have this protocol supported?

Thanks and keep up the good work!

rrooggiieerr commented 8 years ago

Hi,

I dived into the protocol development myself, however I'm facing some problems.

The test/lib-controller.coffee script gives me an error: Error: Cannot find module '../src/controller.coffee'

I'm guessing line 3 of test/lib-controller.coffee should be: controller = require '../lib/controller.js'

However then I get an other error: ReferenceError: describe is not defined

So I left the test/lib-controller.coffee script for what it is and moved on to the alternative method described. I created the following script:

controller = require './index.js'
result = controller.prepareCompressedPulses('591 199 5180 0 0 0 0 0 001100110101001011010010101011010100101011001101001011010011010101010101010101001101010101010101010100110100110100110100101011001002')
console.log result
result2 = controller.fixPulses(result.pulseLengths, result.pulses)
console.log result2

This results in the following output:

{ pulseLengths: [ 199, 591, 5180 ],
  pulses: '110011001010110100101101010100101011010100110010110100101100101010101010101010110010101010101010101011001011001011001011010100110112' }
null

So it looks like controller.fixPulses(result.pulseLengths, result.pulses) returns null, which is not what I was expecting.

Are the protocol development instructions still up to date?

rrooggiieerr commented 8 years ago

Ok, I think I came a bit further in developing the protocol, however it's not working :-( This is what I have so far:

module.exports = (helper) ->
  pulsesToBinaryMapping = {
    '110': '' #header
    '01': '0' #binary 0
    '10': '1' #binary 1
    '112': ''  #footer1
  }
  binaryToPulse = {
    '0': '01'
    '1': '10'
  }
  return protocolInfo = {
    name: 'shutter6'
    type: 'command'
    commands: ["up","down","stop"]
    values:
      id:
        type: "number"
      channel:
        type: "number"
    brands: ["iVisions"]
    pulseLengths: [ 200, 590, 5170 ]
    pulseCount: 132
    decodePulses: (pulses) ->
      console.log("Pulses: #{pulses}")
      # pulses for up, down and stop are something like:
      #
      #
      #

      # we first map the sequences to binary
      binary = helper.map(pulses, pulsesToBinaryMapping)
      console.log("Binary: #{binary}")
      # binary is now something like: '010001100111100011101001100100000000001000000000000101110000100'
      # now we extract the data from that string
      # | 01000110011110001110100110 | 0100000000001000000000 | 000101110000100 |
      # | id                         | channel?               | command         |

      commandcode = binary[48..62]
      console.log("Command Code: #{commandcode}")
      command = (
        switch commandcode
          when '000101110000100' then 'up'
          when '100001110111100' then 'down'
          when '010001110011100' then 'stop'
          when '010010010011101' then undefined
      )
      console.log("Command: #{command}")
      console.log("Id Binary: #{binary[0..26]}")
      console.log("id: #{helper.binaryToNumber(binary, 0, 25)}")
      return result= {
        id: helper.binaryToNumber(binary, 0, 25)
        channel: 0
        command: command
      }

    encodeMessage: (message) ->
      console.log("Id: #{message.id}")
      console.log("Id Binary: #{helper.numberToBinary(message.id, 26)}")

      id = helper.map(helper.numberToBinary(message.id, 26), binaryToPulse)
      console.log("Command: #{message.command}")
      commandcode = (
        switch message.command
          when undefined then ''
          when 'up'  then '000101110000100'
          when 'down' then '100001110111100'
          when 'stop' then '010001110011100'
      )
      console.log("Command Code: #{commandcode}")
      command = helper.map(commandcode, binaryToPulse)

      #pulses = "110#{id}01100101010101010101010110010101010101010101011001011001011001011010100110112110#{id}01100101010101010101010110010101010101010101#{command}112"
      #pulses = "110#{id}01100101010101010101010110010101010101010101011001010110101001011010100101112"
      #pulses = "110011001010110100101101010100101011010100110010110100101100101010101010101010110010101010101010101011001010110101001011010100101112"
      pulses = "110#{id}01100101010101010101010110010101010101010101#{command}112"

      console.log("Pulses: #{pulses}")

      return pulses
  }

When I'm adding this code in Pimatic button presses on the remote are detected, however when I'm sending the screen does nothing.

Any hints and tips?