| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 377616f commit 807833f
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -221,19 +221,23 @@ public void write(String out) { | |||
| 221 | 221 | ||
| 222 | 222 | ||
| 223 | 223 | /** | |
| 224 | - * Adds bytes to be written to the device | ||
| 224 | + * Adds a byte to be written to the device | ||
| 225 | 225 | * | |
| 226 | 226 | * You must call beginTransmission() before calling this function. | |
| 227 | 227 | * The actual writing takes part when read() or endTransmission() is being | |
| 228 | 228 | * called. | |
| 229 | - * @param out single byte to be written | ||
| 229 | + * @param out single byte to be written (0-255) | ||
| 230 | 230 | * @see beginTransmission | |
| 231 | 231 | * @see read | |
| 232 | 232 | * @see endTransmission | |
| 233 | 233 | */ | |
| 234 | - public void write(byte out) { | ||
| 234 | + public void write(int out) { | ||
| 235 | + if (out < 0 || 255 < out) { | ||
| 236 | + System.err.println("The write function can only operate on a single byte at a time. Call it with a value from 0 to 255."); | ||
| 237 | + throw new RuntimeException("Argument does not fit into a single byte"); | ||
| 238 | + } | ||
| 235 | 239 | byte[] tmp = new byte[1]; | |
| 236 | - tmp[0] = out; | ||
| 240 | + tmp[0] = (byte)out; | ||
| 237 | 241 | write(tmp); | |
| 238 | 242 | } | |
| 239 | 243 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -171,9 +171,13 @@ public byte[] transfer(String out) { | |||
| 171 | 171 | * @param out single byte to send | |
| 172 | 172 | * @return bytes read in (array is the same length as out) | |
| 173 | 173 | */ | |
| 174 | - public byte[] transfer(byte out) { | ||
| 174 | + public byte[] transfer(int out) { | ||
| 175 | + if (out < 0 || 255 < out) { | ||
| 176 | + System.err.println("The transfer function can only operate on a single byte at a time. Call it with a value from 0 to 255."); | ||
| 177 | + throw new RuntimeException("Argument does not fit into a single byte"); | ||
| 178 | + } | ||
| 175 | 179 | byte[] tmp = new byte[1]; | |
| 176 | - tmp[0] = out; | ||
| 180 | + tmp[0] = (byte)out; | ||
| 177 | 181 | return transfer(tmp); | |
| 178 | 182 | } | |
| 179 | 183 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments