Summary of the invention
Embodiment of the present invention technical problem to be solved is, provides a kind of coding/decoding method and control method of visible light signal, can decode to the visible light signal received from mobile phone, improves Consumer's Experience.
In order to solve the problems of the technologies described above, embodiment of the present invention provides a kind of coding/decoding method of visible light signal, and described coding/decoding method comprises:
When high level being detected, start timing, be greater than the first preset time period when the duration of high level, the number of the high level of record characterization signal;
When low level being detected, start timing, be greater than the second preset time period when the low level duration, be judged as one group of signal ended; When low duration is greater than the 3rd preset time period, judge that Signal reception is complete;
The each group of signal received is combined, obtains the identification data that visible light signal characterizes.
Another embodiment of the present invention additionally provides a kind of control method of visible signal, and described method comprises:
When high level being detected, start timing, be greater than the first preset duration when the duration of high level, the number of the high level of record characterization signal;
When low level being detected, start timing, be greater than the second preset duration when the low level duration, be judged as one group of signal ended; When low duration is greater than the 3rd preset duration, judge that Signal reception is complete;
The each group of signal received is combined, obtains the identification data that visible light signal characterizes;
Described identification data and the condition preset are contrasted, if coupling, then controls connected functional unit action.
In technique scheme, with the number characterization signal of high level, distinguish with low level delay between each high level group, when high level therefore being detected, the whether useful signal received is judged by timing, if useful signal, then obtain the number of the high level of characterization signal according to the duration of high level; Accordingly, when low level being detected, judge that signal one group receives end, receive interruption or receives according to the low level duration.Therefore, utilize technical scheme of the present invention, can, to the decoding of the visible light signal that mobile phone sends, realize communicating based on visible ray between mobile phone with receiver section.
Embodiment
Below in conjunction with the accompanying drawing in embodiment of the present invention, be clearly and completely described the technical scheme in embodiment of the present invention, obviously, described execution mode is only the present invention's part execution mode, instead of whole execution modes.Based on embodiments of the present invention, those of ordinary skill in the art, not making the every other execution mode obtained under creative work prerequisite, belong to the scope of protection of the invention.
First, in order to those skilled in the art better understand technical scheme of the present invention, brief description is carried out to technical scheme of the present invention below.
The decoding process of the visible light signal that the embodiment of the present invention provides, propose to the coded system representing signal, postpone to distinguish with low level between high level group and group for the number of high level, in described coded system, the duration of each high level is 2ms, the number often organizing high level is less than or equal to 4, often organizes level number and represents 2bit signal.When high level number is 1 in one group of signal, represent 00; When high level number is 2, representation signal 01, when high level number is 3 interval scale signals 10; When high level number is 4 interval scale signals 11.Postpone to distinguish with low level between group and group, low duration is about about 30ms.
Because high level and low level duration can drop in certain scope, therefore, can be decoded to the received signal by the high level on detection I/O pin and low duration during receiving terminal Received signal strength.
Embodiment one,
See Fig. 1, be the coding/decoding method flow chart of a kind of visible light signal that the embodiment of the present invention one provides, this coding/decoding method comprises:
S101: arrange the beginning of rising edge as a high level, trailing edge is as a low level beginning.
S102: when high level being detected, starts timing, is greater than the first preset time period when the duration of high level, the number of the high level of record characterization signal.
Such as, when I/O pin is when rising edge being detected, starting timing, when high level lasting time is greater than 1.5us, thinking effective signal, suppose that the duration of each high level is 2ms, then can according to the number of the duration acquisition high level of high level.
S103: when low level being detected, starts timing, is greater than the second preset time period, is judged as one group of signal ended when the low level duration; When low duration is greater than the 3rd preset time period, judge that Signal reception is complete.
Such as, start timing when I/O pin detects trailing edge, the such as low level duration is 30ms, when the low level duration is greater than 20ms, namely thinks the end mark of one group of signal.Think that Signal reception is complete when I/O pin low duration is greater than 75ms, or Signal reception interrupts, and restarts detection signal.
S104: integrate each group of signal received, obtains the identification data that visible light signal characterizes.
Relation schematic diagram as shown in Figure 2 between signal and level, in Fig. 2, the number of four groups of high level is respectively: 1,4,2,3, four groups of corresponding signals represent 00,11,01,10 respectively, low level time of delay between each signal group is 30ms, signal after combination is a byte, binary representation is: 00110110, and corresponding hexadecimal signal is 0x36.Namely the identification data binary representation obtained is 00110110.
With the number characterization signal of high level, distinguish with low level delay between each high level group, when high level therefore being detected, judge the whether useful signal received by timing, if useful signal, then obtain the number of the high level of characterization signal according to the duration of high level; Accordingly, when low level being detected, judge that signal one group receives end, receive interruption or receives according to the low level duration.Therefore utilize the present embodiment, realize the decoding to the visible light signal that mobile phone sends.
Embodiment two,
See Fig. 3, be the coding/decoding method flow chart of a kind of visible light signal that the embodiment of the present invention two provides, this coding/decoding method comprises:
S201: arrange the beginning of rising edge as a high level, trailing edge is as a low level beginning.
S202: when high level being detected, starts timing, is greater than the first preset time period when the duration of high level, the number of the high level of record characterization signal.
Such as, when I/O pin is when rising edge being detected, starting timing, when high level lasting time is greater than 1.5us, thinking effective signal, suppose that the duration of each high level is 2ms, then can according to the number of the duration acquisition high level of high level.
S203: when low level being detected, starts timing, is greater than the second preset time period, is judged as one group of signal ended when the low level duration; When low duration is greater than the 3rd preset time period, judge that Signal reception is complete.
Such as, start timing when I/O pin detects trailing edge, the such as low level duration is 30ms, when the low level duration is greater than 20ms, namely thinks the end mark of one group of signal.Think that Signal reception is complete when I/O pin low duration is greater than 75ms, or Signal reception interrupts, and restarts detection signal.
S204: integrate each group of signal received, obtains the identification data that visible light signal characterizes.
Such as, four groups of signals of reception represent 00,11,01,10 respectively, and the low level time of delay between each signal group is 30ms, and the signal after combination is a byte, and binary representation is: 00110110, and corresponding hexadecimal signal is 0x36.Namely the identification data binary representation obtained is 00110110.
S205: identification data and the condition preset are contrasted, if coupling, then controls connected functional unit action.
Wherein, identification data and the Condition Matching preset, comprise identification data identical with the condition preset; Or there is corresponding relation in identification data and the condition preset.
In the present embodiment, the visible light signal received is decoded, authentication is carried out to the identification data obtained after decoding, if by authentication, then control connected functional unit action.Thus control the equipment such as household electrical appliance by mobile phone.
Above disclosedly be only some embodiments of the present invention, certainly can not limit the interest field of the present invention with this, in concrete implementation process, different execution modes can also be combined, obtain other embodiment, repeat no more herein.Therefore according to the equivalent variations that the claims in the present invention are done, the scope that the present invention is contained still is belonged to.