| Function declaration: ubyte Multsamp(ubyte inbitno, ubyte dly, ubyte samples, ubyte majority) Multsamp takes multiple samples of the input bit specified by inbitno. The variable dly determines the length of time between samples, and the variable samples determines how many samples are to be taken. If all the samples are ones, a one is returned. If all the samples are zeroes, a zero is returned. If the samples are not all the same, a two is returned. The majority argument isn't implemented in S215XC_Std_func_4.bas, but will be implemented in a future version of S215XC_Std_func_4.bas. |
| proc ubyte
Multsamp(ubyte inbitno, ubyte dly, ubyte samples, ubyte majority) ubyte x, y, z z = GetInBts() //First sample //Gib( ) wasn't used because there is a limit on function nesting x = SelBit(z, inbitno) //Loop "samples" times while samples > 1 do samples = samples - 1 z = dly while z>0 do z = z - 1 Delay(1000) done z = GetInBts() //Sample after delay y = SelBit(z, inbitno) //If all the current sample differs from the original sample, //return a 2 and go back to the calling routine if x != y then return 2 endif done //If we made it this far, all the samples were the same return x //Return a 1 or a 0, depending on what the samples were endproc |